SRCNN.NET does not load
78Alpha opened this issue · 7 comments
Expected Output: Model would load and proceed to show lighting of examples/custom image
Obtained Output: Failure to load model with the correct dependencies installed. Error reason is unknown but can be guessed at where the root issue is.
Code snippet
Traceback (most recent call last): File "example001.py", line 18, in <module> from ProjectPaintingLight import run File "C:\Users\prome\PycharmProjects\PaintingLight\PaintingLight-master\code\ProjectPaintingLight.py", line 26, in <module> srcnn = tf.keras.models.load_model('srcnn.net') File "C:\Users\prome\PycharmProjects\PaintingLight\core\lib\site-packages\tensorflow\python\keras\_impl\keras\models.py", line 244, in load_model model_config = json.loads(model_config.decode('utf-8')) AttributeError: 'str' object has no attribute 'decode'
I have gotten this program to work in the past, varies on day I installed python, some builds it will work, some builds it won't, even if they use the same dependencies and so on... A standalone version (packaged) or even a docker image might be useful, as this "app" is touchy enough to break from a number of other factors.
It seem that the error comes from keras installation. What is the version of keras inside of the fensorflow you have installed?
I had thought it was keras but no version was mentioned in the install instructions, or one that was used specifically...
The one in my VENV is... well... unmarked. It doesn't have any keras version listed, however, the script is trying to use tensorflow.keras built into the 1.4.0
Looked into it further, and it appears to be version 2.0.8-tf
out-of-date:
pip install opencv-python
pip install opencv-contrib-python
pip install h5py
error:
Traceback (most recent call last):
File "example002.py", line 18, in <module>
from ProjectPaintingLight import run
File "D:\PaintingLight\code\ProjectPaintingLight.py", line 27, in <module>
srcnn = tf.keras.models.load_model('srcnn.net')
File "E:\VirtualEnvs\paint_lighting_3\lib\site-packages\tensorflow\python\keras\_impl\keras\models.py", line 244, in load_model
model_config = json.loads(model_config.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'
Solution
Create a new virtual environment.
pip install opencv-python==4.2.0.34
pip install opencv-contrib-python==4.2.0.34
pip install h5py==2.10.0
pip install tensorflow==1.4.0
pip install scipy==1.1.0
pip install trimesh==2.37.1
For windows, use Python 3.6 x86-64 (can't use other python version), and install:
pip install Rtree-0.9.3-cp36-cp36m-win_amd64.whl
Ref: #2
Following the solution, I was presented with
On entry to DGEBAL parameter number 3 had an illegal value
On entry to DGEHRD parameter number 2 had an illegal value
On entry to DORGHR DORGQR parameter number 2 had an illegal value
On entry to DHSEQR parameter number 4 had an illegal value
ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
File "example001.py", line 1, in <module>
import cv2
File "C:\Users\prome\PycharmProjects\PaintingLight\venv\lib\site-packages\cv2\__init__.py", line 5, in <module>
from .cv2 import *
ImportError: numpy.core.multiarray failed to import
pip install numpy==1.18.2