SanoKyohei / Secreit

1 stars 4 forks source link

I am having trouble using your repo due to vague module versions. #2

Open kroman4 opened 3 years ago

kroman4 commented 3 years ago

Would you be able to add a requirements.txt with the exact versions you used.

I tried using the following module versions and python 3.6. numpy==1.19.3 keras==2.2.4 opencv-python tensorflow==2.0

I am also unsure how to fully run the code as the instructions are not very in depth for someone at my level. Can you give an example of the commands used to determine the estrus stage of an image that the user submits? Additionally, do the images have to be in .png format or can they be .tiff?

Thanks!

SanoKyohei commented 3 years ago

About requirements.txt: I added now

About Example code: Please refer to Example.ipynb

About .tiff file Actually I didn`t check it, but I think it will work.

Concrete18 commented 3 years ago

opencv-python 4.1.1 did not seem to exist but this was close and installed fine. opencv-python==4.1.1.26

I found that Keras 2.2.4 is giving this import error. I am running the example (Example.ipynb) in VSCode after installing everything but it gets the following error.

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-f457f0f1cf48> in <module>
----> 1 import Secreit
      2 from keras.preprocessing import image
      3 import numpy as np
      4 from matplotlib import pyplot as plt
      5 import matplotlib as mpl

d:\Google Drive\Coding\Python\Scripts\Secreit\Secreit.py in <module>
----> 1 from keras import models
      2 from keras import layers
      3 import pickle
      4 from keras.applications import VGG16
      5 from keras import optimizers

ModuleNotFoundError: No module named 'keras'
Concrete18 commented 3 years ago

Are you using Anaconda? I tried using the following versions using a venv.

numpy==1.19.1
opencv-python==4.1.1.26 # 4.1.1 did not exist
keras==2.2.4
tensorflow==2.2.0

A Pip freeze output might help from your working environment.

SanoKyohei commented 3 years ago

Do you really install keras?? "ModuleNotFoundError: No module named 'keras' " means you don't install keras correctly.

You should reinstall keras and type "import keras" to check whether you install it correctly.

Concrete18 commented 3 years ago

This is so strange.

I installed again and same error. This is what it tells me when I import keras within the venv enviroment using python terminal.

>>> import keras
Using TensorFlow backend.
2020-12-18 13:56:47.936810: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
SanoKyohei commented 3 years ago

How about "from keras import models" I don`t know why you can import keras, but you cant do the same thing when using Secreit.

How about copying and pasting all the Secreit.py and use it without importing Secreit.

Concrete18 commented 3 years ago

How are you running the Example.ipynb file? VSCode may be failing to use the VENV which would cause these issues.

It is getting further without errors but now this comes up

RuntimeError: tf.gradients is not supported when eager execution is enabled. Use tf.GradientTape instead.

due to this line.

grads = K.gradients(P_output, last_conv_layer.output)[0]
SanoKyohei commented 3 years ago

I`m using Anaconda, not VENV.

kroman4 commented 3 years ago

Keras 2.2.4 does not work well with tensorflow 2.0 (https://github.com/keras-team/keras/issues/12379). Using anaconda I created an environment with the following versions, which allowed me to successfully run your Example.ipynb with the D.png:

numpy==1.19.1 opencv-python==4.1.1.26 keras==2.2.4 tensorflow==1.13.1 matplotlib

However, when I try to run the jupyter notebook with the E.png, i get the following error:

ValueError Traceback (most recent call last)

in 1 predict=Secreit.predict(img, model) ----> 2 print('D:'+str(round(predict[0]*100))+'%, E:'+str(round(predict[1]*100))+'%, P:'+str(round(predict[2]*100))+'%') ValueError: cannot convert float NaN to integer When I add print(predict), the output is [ 0. nan 0.] I also tested E_a_E0010005_Auto3_train.png and print(predict) resulted in [5.4724413e-11 nan 8.0592477e-12]
SanoKyohei commented 3 years ago

It was caused by "inf". Now I fixed Secreit.py.