Closed aytek03 closed 2 years ago
Also when I run this code
python evaluate.py --gpu_ids 0 --gpu_memory 0.2 combined_model ./pretrained/CVPR19/Avenue/combined_model/_mp_Grobust_Lrobust_Orobustconcatdown/01_2018_11_13_06_36_20 ./data/HR-Avenue/testing/trajectories/01 ./data/HR-Avenue/testing/frame_level_masks/01 --video_resolution 640x360 --overlapping_trajectories
I got errors:
x.assign(np.asarray(value, dtype=dtype_numpy(x))) ValueError: Cannot assign value to variable ' rnn/stacked_rnn_cells/gru_cell/bias:0': Shape mismatch.The variable shape (2, 12), and the assigned value shape (12,) are incompatible.
I solved this problem.
Hi @aytek03
Could you tell me how to solve it? I'm facing the same problem.
Hi @aytek03
Could you tell me how to solve it? I'm facing the same problem.
Hi, this problem is caused by windows and uptaded python libraries. I use Linux and downgrade the python libraries.
Hi @aytek03, thank you for your quick response! I downgraded the libraries and fixed some code below in Keras, it worked on Windows.
--- Lib/site-packages/keras/engine/topology.py
+++ Lib/site-packages/keras/engine/topology.py
@@ -3339 +3339,7 @@
- original_keras_version = f.attrs['keras_version'].decode('utf8')
+ keras_version = f.attrs['keras_version']
+ if isinstance(keras_version, bytes):
+ original_keras_version = keras_version.decode('utf8')
+ elif isinstance(keras_version, str):
+ original_keras_version = keras_version
+ else:
+ raise Exception("Unexpected type of \"f.attrs['keras_version']\": " + type(keras_version))
@@ -3343 +3349,7 @@
- original_backend = f.attrs['backend'].decode('utf8')
+ backend = f.attrs['backend']
+ if isinstance(backend, bytes):
+ original_backend = backend.decode('utf8')
+ elif isinstance(backend, str):
+ original_backend = backend
+ else:
+ raise Exception("Unexpected type of \"f.attrs['backend']\": " + type(backend))
Hi @akirasano-exwzd ,
I am happy to solve this problem. I have Linux server so I use Linux. :)
Hi @akirasano-exwzd,
I want to implement in windows instead of Linux. I can implement train.py but I cannot implement evaulate. I think this problem is caused by environment.yml. In this work, environment.yml is based on MacOS I guess. We need to convert it to Wİndows version. I converted but it did not worked.
Could you sent me environment.yml in windows version? Or how can you solve?
Hi @aytek03,
I solved the shape incompatible problem by downgrading the libraries.
I make my environment in Windows by the pip instead of the anaconda, thus I don't use environment.yml.
I decided on the library versions by reference to the environment.yaml.
This is the output of pip freeze
. It may contain some unnecessary libraries.
Python version is 3.6.8.
absl-py==1.0.0
astor==0.8.1
atomicwrites==1.4.0
attrs==21.4.0
black==22.1.0
bleach==1.5.0
cached-property==1.5.2
click==8.0.3
colorama==0.4.4
cycler==0.11.0
dataclasses==0.8
flake8==4.0.1
gast==0.5.3
grpcio==1.43.0
h5py==3.1.0
html5lib==0.9999999
importlib-metadata==4.2.0
iniconfig==1.1.1
Keras==2.1.6
kiwisolver==1.3.1
Markdown==3.3.6
matplotlib==2.2.2
mccabe==0.6.1
mypy==0.931
mypy-extensions==0.4.3
numpy==1.19.5
opencv-python==3.4.1.15
packaging==21.3
pathspec==0.9.0
platformdirs==2.4.0
pluggy==1.0.0
protobuf==3.19.3
py==1.11.0
pycodestyle==2.8.0
pyflakes==2.4.0
pyparsing==3.0.7
pytest==7.0.1
python-dateutil==2.8.2
pytz==2021.3
PyYAML==6.0
scikit-learn==0.20.0
scipy==1.5.4
six==1.16.0
tensorboard==1.8.0
tensorflow==1.8.0
termcolor==1.1.0
tomli==1.2.3
tqdm==4.62.3
typed-ast==1.5.2
typing_extensions==4.0.1
Werkzeug==2.0.2
zipp==3.6.0
Hi @akirasano-exwzd ,
I added this library and fixed some code below in Keras,
I delete ".decode('utf8')" part from topology.py.
Lib/site-packages/keras/engine/topology.py
3339
if 'keras_version' in f.attrs:
original_keras_version = f.attrs['keras_version'].decode('utf8')
else:
original_keras_version = '1'
if 'backend' in f.attrs:
original_backend = f.attrs['backend'].decode('utf8')
new version of topology.py.
if 'keras_version' in f.attrs:
original_keras_version = f.attrs['keras_version']
else:
original_keras_version = '1'
if 'backend' in f.attrs:
original_backend = f.attrs['backend']
Hi @akirasano-exwzd again, @RomeroBarata
I implemented another database that called 'HR-Crime' . I trained but I cannot evaulate again.
I got error below:
File ".....\lib\site-packages\keras\engine\topology.py", line 2940, in
I solved another decode problem you mentioned above, but I cannot solve this decode problem.
Any ideas?
Hi @aytek03 ,
Downgrading h5py to 2.8.0 may work. In my environment, the first decode problem was also solved this way.
Hi @akirasano-exwzd
I managed to evaulate from this example link => https://github.com/RomeroBarata/skeleton_based_anomaly_detection#evaluate-mped-rnn-on-hr-avenue.
When I train myself (Train Models from Scratch in Avenue dataset), it works but I could not evaulate.
I downgraded to h5py to 2.8.0 and I got this error: ValueError: You are trying to load a weight file containing 20 layers into a model with 12 layers.
Any libraries that we have to change?
Hi @aytek03,
From the error message, the model types are different in training and evaluation. Could you show the commands both in training and evaluation?
@akirasano-exwzd Here is my train code: (I do not use GPU)
python train.py --gpu_ids -1 --gpu_memory 0 combined_model ./data/HR-Avenue/training/trajectories/01 --video_resolution 640x360 --message_passing --reconstruct_original_data --multiple_outputs --multiple_outputs_before_concatenation --input_length 12 --rec_length 12 --pred_length 6 --reconstruct_reverse --cell gru --global_hidden 8 --local_hidden 16 --output_activation linear --optimiser adam --learning_rate 0.001 --loss mse --epochs 80 --batch_size 256 --global_normalisation robust --local_normalisation robust --out_normalisation robust --root_log_dir ./visualize
here is my evaulate code.
python evaluate.py --gpu_ids -1 --gpu_memory 0 combined_model ./visualize/01_2022_03_01_17_25_51 ./data/HR-Avenue/testing/trajectories/01 ./data/HR-Avenue/testing/frame_level_masks/01 --video_resolution 640x360 --overlapping_trajectories
I got an error...
@aytek03 Sorry for the late reply.
The evaluation script decides the model parameters by the path of trained model files. The relations of the parameters and path strings enabled in your train code are below.
You could rename the path of the trained model files to "mp_down_Grobust_LrobustOrobust/01_2022_03_01_17_25_51" and run train.py.
@akirasano-exwzd There is no problem.
Thank you so much for solution. It works.
Also I can implement another database (HR-Crime) and works.
Sometimes I got an error:
ValueError: Input contains infinity or a value too large for dtype('float32').
To solve this problem, I change the file names then work.
Thank you again :)
@akirasano-exwzd just one question...
When I implement train.py with 'HR-Crime' dataset (i mentioned above), I got error in training set :
ValueError: Input contains infinity or a value too large for dtype('float32').
I deleted and extracted some files among training set and I got no error.
Is it possible that I don't get this error without deleting any files?
@aytek03
The error message seems to mean the input date has some NaN or Inf values, thus you can add some pre-process, which removes or replace these values from input data, instead of deleting some files.
You may want to create a new issue if you have further discussion 😃
@akirasano-exwzd
I thought so, too.
Thanks :)
Hi sir,
When I run this code :
python evaluate.py --gpu_ids 0 --gpu_memory 0.2 combined_models ./pretrained/CVPR19/ShanghaiTech/combined_model/_mp_Grobust_Lrobust_Orobustconcatdown\ ./data/HR-ShanghaiTech/testing/trajectories ./data/HR-ShanghaiTech/testing/frame_level_masks --video_resolution 856x480 --overlapping_trajectories
I got this error :
x.assign(np.asarray(value, dtype=dtype_numpy(x))) ValueError: Cannot assign value to variable ' rnn/stacked_rnn_cells/gru_cell/bias:0': Shape mismatch.The variable shape (2, 24), and the assigned value shape (24,) are incompatible.
How i can solve this problem?