MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Magic mirror using hdf5

    Scheduled Pinned Locked Moved Unsolved Troubleshooting
    3 Posts 2 Posters 1.1k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • 1 Offline
      16KYJ
      last edited by 16KYJ

      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.

      1 Reply Last reply Reply Quote 0
      • 1 Offline
        16KYJ
        last edited by

        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.

        S 1 Reply Last reply Reply Quote 0
        • S Away
          sdetweil @16KYJ
          last edited by

          @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

          see https://stackoverflow.com/questions/595305/how-do-i-get-the-path-of-the-python-script-i-am-running-in

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Enjoying MagicMirror? Please consider a donation!
          MagicMirror created by Michael Teeuw.
          Forum managed by Sam, technical setup by Karsten.
          This forum is using NodeBB as its core | Contributors
          Contact | Privacy Policy