Open Antwnina opened 4 years ago
Are you trying to take pictures using the webcam? If that's the case, you can use this example as a reference: https://github.com/thoughtworksarts/EmoPy/blob/master/EmoPy/examples/fermodel_example_webcam.py
Before doing that, please make sure you have downloaded the last version of EmoPy and installed it properly, as described in our README file. You can verify that by running the tests first.
@cptanalatriste
also i tried to add all of the rest emotions and there is error
def get_emotion_from_camera():
# Specify the camera which you want to use. The default argument is '0'
video_capture = cv2.VideoCapture(0)
file = 'image_data/image.jpg'
frame = capture_image(video_capture, file)
if frame is not None:
# Can choose other target emotions from the emotion subset defined in
# fermodel.py in src directory. The function
# defined as `def _check_emotion_set_is_supported(self):`
target_emotions = ['calm', 'anger', 'happiness', 'surprise', 'disgust', 'fear', 'sadness'] #'calm', 'anger', 'happiness']
model = FERModel(target_emotions, verbose=True)
frame_string = model.predict(file)
display_prediction(frame, frame_string)
error in terminal
python3.6 fermodel_ex_webcam_motor.py
Using TensorFlow backend.
/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
/usr/local/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: compiletime version 3.4 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.6
return f(*args, **kwds)
/usr/local/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: builtins.type size changed, may indicate binary incompatibility. Expected 432, got 412
return f(*args, **kwds)
/usr/local/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:541: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/usr/local/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:542: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/usr/local/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:543: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
/usr/local/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:544: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/usr/local/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:545: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
/usr/local/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:550: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
Capturing image ...
Image written to: image_data/image.jpg
Initializing FER model parameters for target emotions: ['calm', 'anger', 'happiness', 'surprise', 'disgust', 'fear', 'sadness']
Traceback (most recent call last):
File "fermodel_ex_webcam_motor.py", line 106, in <module>
get_emotion_from_camera()
File "fermodel_ex_webcam_motor.py", line 76, in get_emotion_from_camera
model = FERModel(target_emotions, verbose=True)
File "/usr/local/lib/python3.6/site-packages/EmoPy-0.0.5-py3.6.egg/EmoPy/src/fermodel.py", line 41, in __init__
File "/usr/local/lib/python3.6/site-packages/EmoPy-0.0.5-py3.6.egg/EmoPy/src/fermodel.py", line 45, in _initialize_model
File "/usr/local/lib/python3.6/site-packages/EmoPy-0.0.5-py3.6.egg/EmoPy/src/fermodel.py", line 112, in _choose_model_from_target_emotions
File "/usr/local/lib/python3.6/site-packages/keras/engine/saving.py", line 417, in load_model
f = h5dict(filepath, 'r')
File "/usr/local/lib/python3.6/site-packages/keras/utils/io_utils.py", line 186, in __init__
self.data = h5py.File(path, mode=mode)
File "/usr/local/lib/python3.6/site-packages/h5py/_hl/files.py", line 408, in __init__
swmr=swmr)
File "/usr/local/lib/python3.6/site-packages/h5py/_hl/files.py", line 173, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5f.pyx", line 88, in h5py.h5f.open
OSError: Unable to open file (file signature not found)
but i have h5py because i checked it you cna see below
pi@raspberrypi:~/EmoPy/EmoPy/examples $ sudo apt-get install python3-h5py
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-h5py is already the newest version (2.8.0-3).
0 upgraded, 0 newly installed, 0 to remove and 117 not upgraded.
pi@raspberrypi:~/EmoPy/EmoPy/examples $ sudo pip3 install h5py
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: h5py in /usr/local/lib/python3.6/site-packages (2.10.0)
Requirement already satisfied: numpy>=1.7 in /usr/local/lib/python3.6/site-packages (from h5py) (1.17.4)
Requirement already satisfied: six in /usr/local/lib/python3.6/site-packages (from h5py) (1.13.0)
pi@raspberrypi:~/EmoPy/EmoPy/examples $ ipython
Python 3.6.9 (default, Nov 11 2019, 21:26:11)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.9.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import h5py
In [2]: h5py.run_tests()
============================= test session starts ==============================
platform linux -- Python 3.6.9, pytest-5.2.2, py-1.8.0, pluggy-0.13.0
rootdir: /home/pi/EmoPy
collected 549 items
../../tests/test_attribute_create.py .... [ 0%] ../../tests/test_attrs.py ................s [ 3%] ../../tests/test_attrs_data.py .................... [ 7%] ../../tests/test_base.py ..... [ 8%] ../../tests/test_completions.py .. [ 8%] ../../tests/test_dataset.py .s.......x.................................. [ 16%] ...............................x.......................... [ 27%] ../../tests/test_dataset_getitem.py .................................... [ 33%] .............x...................................s [ 42%] ../../tests/test_dataset_swmr.py ssss.......... [ 45%] ../../tests/test_datatype.py .. [ 45%] ../../tests/test_deprecation.py . [ 46%] ../../tests/test_dimension_scales.py ....s................ [ 49%] ../../tests/test_dims_dimensionproxy.py . [ 50%] ../../tests/test_dtype.py ................ssss [ 53%] ../../tests/test_file.py .............ss...ssss....................s.... [ 62%] ..... [ 63%] ../../tests/test_file2.py ................. [ 66%] ../../tests/test_file_image.py .. [ 66%] ../../tests/test_filters.py ... [ 67%] ../../tests/test_group.py .................................ssssss....... [ 75%] ............................................ [ 83%] ../../tests/test_h5.py ..... [ 84%] ../../tests/test_h5d_direct_chunk.py .... [ 85%] ../../tests/test_h5f.py ..... [ 86%] ../../tests/test_h5p.py ........ [ 87%] ../../tests/test_h5pl.py ...... [ 88%] ../../tests/test_h5t.py .... [ 89%] ../../tests/test_objects.py ... [ 89%] ../../tests/test_selections.py .... [ 90%] ../../tests/test_slicing.py ........................ [ 95%] ../../tests/test_threads.py .. [ 95%] ../../tests/test_vds/test_highlevel_vds.py ...... [ 96%] ../../tests/test_vds/test_lowlevel_vds.py ... [ 97%] ../../tests/test_vds/test_virtual_source.py ................ [100%]
=========================================== warnings summary ===========================================
tests/test_dataset_getitem.py::Test1DZeroFloat::test_mask
/usr/local/lib/python3.6/site-packages/h5py/_hl/dataset.py:533: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use array.size > 0
to check that an array is not empty.
if args == (Ellipsis,) or args == tuple():
-- Docs: https://docs.pytest.org/en/latest/warnings.html ======================= 521 passed, 25 skipped, 3 xfailed, 1 warnings in 21.61s ======================== Out[2]: 0
In [3]: quit()
Hello, i want to capture some pictures of mine and load them to fermodel_example.py. How do I do that? I've changed the size frame and made the .png gray but it is not accepted
and this is the terminal output when i run the example (i made duplicate)