Read the statement by Michael Teeuw here.
Magic mirror using hdf5
-
Hello!
I am making emotion detection module but some error message appears.Traceback (most recent call last): File "modules/MMM-Test/face.py", line 11, in <module> emotion_classifier = load_model(os.getcwd()+'/files/emotion_model.hdf5', compile=False) File "/home/pi/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/save.py", line 140, in load_model loader_impl.parse_saved_model(filepath) File "/home/pi/.local/lib/python3.7/site-packages/tensorflow_core/python/saved_model/loader_impl.py", line 83, in parse_saved_model constants.SAVED_MODEL_FILENAME_PB)) OSError: SavedModel file does not exist at: /home/pi/MagicMirror/files/emotion_model.hdf5/{saved_model.pbtxt|saved_model.pb} at PythonShell.parseError (/home/pi/MagicMirror/modules/MMM-Test/node_modules/python-shell/index.js:268:21) at terminateIfNeeded (/home/pi/MagicMirror/modules/MMM-Test/node_modules/python-shell/index.js:139:32) at ChildProcess.<anonymous> (/home/pi/MagicMirror/modules/MMM-Test/node_modules/python-shell/index.js:131:13) at ChildProcess.emit (events.js:182:13) at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12) executable: 'python3', options: null, script: 'modules/MMM-Test/face.py', args: null, exitCode: 1 } MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection? If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues Shutting down server...
And finally I found that this error message appears when
there is no “emotion_model.hdf5” in file/home/pi/MagicMirror/files/.
When I run it with python3 it works well, and if I intentionally change the name of hdf5 file as “happy_model.hdf5” and run it with python3, same error appears.
So I realized that this error means that there is no hdf5 file in the directory.
Even though I can run it with python3, when I try to run it with magicmirror, because of that error message I couldn’t run it with magic mirror.I even eliminate everything except the line that means loading hdf5 file as follows.
import cv2 import numpy as np from tensorflow.keras.preprocessing.image import img_to_array from tensorflow.keras.models import load_model import os import json import sys import time # Face detection XML load and trained model loading face_detection = cv2.CascadeClassifier(os.getcwd()+'/files/haarcascade_frontalface_default.xml') emotion_classifier = load_model(os.getcwd()+'/files/emotion_model.hdf5', compile=False)
But same error message appears.
Is there anyone who have ever experienced this problem or who can give me advice?
Thank you. -
I finally found that if I start magic mirror using “npm start”
even if python code is not in ~/Magicmirror folder, os.getcwd() return ~/Magicmirror folder.
I thought that it will return the location of the python code. -
@16KYJ said in Magic mirror using hdf5:
os.getcwd()
it returns the current working directory… (result of cd)
you would have to modify the script to find where IT is located