how to install model_evaluation_utils - machine-learning

I'm trying to model evaluate the performance of our deep learning models. And below is my code. However, I still get
No module named 'model_evaluation_utils'
Is there any pip installation or conda that could solve this problem?
from keras.preprocessing.image import load_img, img_to_array, array_to_img
from keras.models import load_model
import model_evaluation_utils as meu # throws error

Implementation of "model_evaluation_utils" can be found in the following github repository:
link

I think it's not a publicly available library, there must be a model_evaluation_utils.py file which is imported in the code and is used.

Related

How to use K.get_session in Tensorflow 2.0 or how to migrate it?

def __init__(self, **kwargs):
self.__dict__.update(self._defaults) # set up default values
self.__dict__.update(kwargs) # and update with user overrides
self.class_names = self._get_class()
self.anchors = self._get_anchors()
self.sess = K.get_session()
RuntimeError: get_session is not available when using TensorFlow 2.0.
Tensorflow 2.0 does not expose the backend.get_session directly any more but the code still there and expose for tf1.
https://github.com/tensorflow/tensorflow/blob/r2.0/tensorflow/python/keras/backend.py#L465
You can use it with tf1 compatible interface:
sess = tf.compat.v1.keras.backend.get_session()
Or import tenforflow backend with internal path:
import tensorflow.python.keras.backend as K
sess = K.get_session()
In order to avoid using get_session after tensorflow 2.0 upgrade, Use tf.distribute.Strategy to get model. To load model, use tf.keras.models.load_model
import tensorflow as tf
another_strategy = tf.distribute.MirroredStrategy()
with another_strategy.scope():
model = Service.load_deep_model()
def load_deep_model(self, model):
loaded_model = tf.keras.models.load_model("model.h5")
return loaded_model
Hope this helps. As this worked for me.
I have tried to explain same at this utility article as well. https://www.javacodemonk.com/runtimeerror-get_session-is-not-available-when-using-tensorflow-2-0-f7238546
Probably has something to do with tf 2.0 eager execution that is enabled by default.
Try
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
I had the same error and tried installing and uninstalling. In the end, I found that the library was not actually installed correctly.
I went through each library in my:
C:\Users\MyName\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\
I tracked down the file in within the site-packages in Keras, which was calling from the Tensorflow library, which was calling from another folder. I found the final folder had the get_session(), but this was not being called in. When I checked the directory, I found that get_session wasn't being loaded in. Within the file directory /tensorflow/keras/backend.py it was importing everything, but missed out the get_session.
To fix this I added this line:
from tensorflow.python.keras.backend import get_session
Then saved it. The next time I ran my code it was fine.
I gave the same answer for this page How to fix ' module 'keras.backend.tensorflow_backend' has no attribute '_is_tf_1''

How to import custom modules in google colab? (Solution given here not working)

I'm trying to import a custom module called 'clusterer.py' into my colab notebook. But the import function is not able to find the file. Is there any other way to import custom modules?
After mounting the drive, I have already tried this approach: How to import custom modules in google colab? with the result: 'No module named 'clusterer''
!ls /content/gdrive/My\ Drive/Colab\ Notebooks/Omdena_Mars_Anomaly_Detection/*.py
!cat /content/gdrive/My\ Drive/Colab\ Notebooks/Omdena_Mars_Anomaly_Detection/clusterer.py
import sys
sys.path.append('/content/gdrive/My\ Drive/Colab\ Notebooks/Omdena_Mars_Anomaly_Detection')
import clusterer
The output is as follows:
'/content/gdrive/My Drive/Colab Notebooks/Omdena_Mars_Anomaly_Detection/clusterer.py'
'/content/gdrive/My Drive/Colab Notebooks/Omdena_Mars_Anomaly_Detection/feature_extractor.py'
[Contents of the module 'clusterer.py']
ModuleNotFoundError: No module named 'clusterer'
Ok, I think I figured out one solution. In my case, I had to physically go inside the directory where the files were. This is what I did
1a. Restart the kernel but 'resetting all runtimes', specially if you've just added your file.py to the directory.
1b.cd gdrive/My Drive/Colab Notebooks/Omdena_Mars_Anomaly_Detection
!ls /content/gdrive/My\ Drive/Colab\Notebooks/Omdena_Mars_Anomaly_Detection/*.py
!cat /content/gdrive/My\ Drive/Colab\ Notebooks/Omdena_Mars_Anomaly_Detection/mylib.py
import sys
sys.path.append('/content/gdrive/My\ Drive/Colab\ Notebooks/Omdena_Mars_Anomaly_Detection')
5.import clusterer
Worked for me.
Thanks

Could not load lang::java::jdt::Java

When trying to import JAVA modules I receive an error:
// JAVA imports
import lang::java::jdt::Java;
import lang::java::jdt::JDT;
import lang::java::jdt::JavaADT;
Could not load lang::java::jdt::Java
In the console:
rascal>import lang::java::jdt::Java;
|prompt:///|(0,29,<1,0>,<1,29>): Could not import module lang::java::jdt::Java: can not find in search path
Advice: |http://tutor.rascal-mpl.org/Errors/Static/ModuleImport/ModuleImport.html|
I'm using Eclipse and am trying to use the AstNode datatype. Any ideas?
The JDT modules have been replaced a while back by the m3 model.
While they are a bit different, the AST part should be comparable.
Check the m3 ast documentation and the Measuring java recipe.
Is this an old project you are trying to get up and running?

Could not find class 'weka.core.FastVector',

I am using weka for my project. but get the error info"could not find class weka.core.FastVector" on the line below. I have already added weka.jar from the build path of the project by adding external jar file. How should I solve this problem? Thanks a lot for your time on reviewing my question.
import weka.core.Attribute;
import weka.core.FastVector;
import weka.core.Instance;
import weka.core.Instances;
FastVector atts;
private void setUpARFF(){
atts = new FastVector();}
I know that FastVector was marked as obsolete a while back, perhaps they've finally removed it. Are you using the dev version of weka (or what version are you using)? FastVector can be replaced with ArrayList (in dev version) so use that instead.

how to create exe of Python Code using opencv with or without py2exe?

i have some Python Code working properly its some kinda simple thing using opencv.
for example
import cv2
x = cv2.imread('Dog6.jpg')
cv2.imwrite('new2.jpg')
setup.py is
from distutils.core import setup
import py2exe
import cv2
setup(console=['name.py'])
but i am unable to create exe of this code with py2exe.
is there another method to create exe of such program ?
Error is
ImportError:numpy.core.multiarray failed to import
Put the line:
import numpy
Into your script, i.e the first file and try again.

Resources