WaqasSultani / AnomalyDetectionCVPR2018

502 stars 182 forks source link

Error while compile model in TrainingAnomalyDetector_public.py #71

Closed iShahad97 closed 4 years ago

iShahad97 commented 4 years ago

Hi, thanks for the nice work! I met some problem when I tried to run TrainingAnomalyDetector_public.py

Versions: keras.json:

{ "floatx": "float32", "epsilon": 1e-07, "backend": "theano", "image_dim_ordering": "tf" }

Theano: 1.0.2 Python: 3.7.6 Ubuntu: 16.04

Problem: Keras==1.2.2:

Using Theano backend. Create Model Traceback (most recent call last):

File "", line 1, in runfile('/media/systemseng/WhitePassport/Real-world Anomaly Detection in Surveillance Videos/AnomalyDetectionCVPR2018-master/TrainingAnomalyDetector_public.py', wdir='/media/systemseng/WhitePassport/Real-world Anomaly Detection in Surveillance Videos/AnomalyDetectionCVPR2018-master')

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 827, in runfile execfile(filename, namespace)

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "/media/systemseng/WhitePassport/Real-world Anomaly Detection in Surveillance Videos/AnomalyDetectionCVPR2018-master/TrainingAnomalyDetector_public.py", line 32, in model.add(Dropout(0.6))

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/keras/models.py", line 332, in add output_tensor = layer(self.outputs[0])

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/keras/engine/topology.py", line 572, in call self.add_inbound_node(inbound_layers, node_indices, tensor_indices)

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/keras/engine/topology.py", line 635, in add_inbound_node Node.create_node(self, inbound_layers, node_indices, tensor_indices)

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/keras/engine/topology.py", line 166, in create_node output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/keras/layers/core.py", line 111, in call x = K.in_train_phase(dropped_inputs, lambda: x)

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/keras/backend/theano_backend.py", line 1174, in in_train_phase x = theano.ifelse.ifelse(_LEARNING_PHASE, x, alt)

AttributeError: module 'theano' has no attribute 'ifelse'

Keras==1.1.0:

Using Theano backend. Create Model Traceback (most recent call last):

File "", line 1, in runfile('/media/systemseng/WhitePassport/Real-world Anomaly Detection in Surveillance Videos/AnomalyDetectionCVPR2018-master/TrainingAnomalyDetector_public.py', wdir='/media/systemseng/WhitePassport/Real-world Anomaly Detection in Surveillance Videos/AnomalyDetectionCVPR2018-master')

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 827, in runfile execfile(filename, namespace)

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "/media/systemseng/WhitePassport/Real-world Anomaly Detection in Surveillance Videos/AnomalyDetectionCVPR2018-master/TrainingAnomalyDetector_public.py", line 278, in model.compile(loss=custom_objective, optimizer=adagrad)

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/keras/models.py", line 547, in compile **kwargs)

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/keras/engine/training.py", line 622, in compile sample_weight, mask)

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/keras/engine/training.py", line 324, in weighted score_array = fn(y_true, y_pred)

File "/media/systemseng/WhitePassport/Real-world Anomaly Detection in Surveillance Videos/AnomalyDetectionCVPR2018-master/TrainingAnomalyDetector_public.py", line 252, in custom_objective sub_sum_l1 = sub_sum_l1[:n_exp]

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/theano/tensor/var.py", line 572, in getitem return theano.tensor.subtensor.advanced_subtensor(self, *args)

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/theano/gof/op.py", line 615, in call node = self.make_node(*inputs, **kwargs)

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/theano/tensor/subtensor.py", line 2227, in make_node return super(AdvancedSubtensor, self).make_node(x, *index)

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/theano/tensor/subtensor.py", line 2178, in make_node index = tuple(map(as_index_variable, index))

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/theano/tensor/subtensor.py", line 2072, in as_index_variable return make_slice(idx)

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/theano/gof/op.py", line 615, in call node = self.make_node(*inputs, **kwargs)

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/theano/tensor/type_other.py", line 39, in make_node list(map(as_int_none_variable, inp)),

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/theano/tensor/type_other.py", line 20, in as_int_none_variable raise TypeError('index must be integers')

TypeError: index must be integers

Thanks again for your real wonderful job! @WaqasSultani

iShahad97 commented 4 years ago

I tracked the error and seems that n_exp variable is float, so I converted it to integer, the model is compiled and start training, I'm not sure of what I've done but It is moving on! Then I got an error on load_dataset_Train_batch function:

Using Theano backend. Create Model Starting training... Traceback (most recent call last):

File "", line 1, in runfile('/media/systemseng/WhitePassport/Real-world Anomaly Detection in Surveillance Videos/AnomalyDetectionCVPR2018-master/TrainingAnomalyDetector_public.py', wdir='/media/systemseng/WhitePassport/Real-world Anomaly Detection in Surveillance Videos/AnomalyDetectionCVPR2018-master')

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 827, in runfile execfile(filename, namespace)

File "/home/systemseng/anaconda3/envs/salohaydib/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "/media/systemseng/WhitePassport/Real-world Anomaly Detection in Surveillance Videos/AnomalyDetectionCVPR2018-master/TrainingAnomalyDetector_public.py", line 313, in inputs, targets=load_dataset_Train_batch(AbnormalPath, NormalPath) # Load normal and abnormal video C3D features

File "/media/systemseng/WhitePassport/Real-world Anomaly Detection in Surveillance Videos/AnomalyDetectionCVPR2018-master/TrainingAnomalyDetector_public.py", line 101, in load_dataset_Train_batch Abnor_list_iter = Abnor_list_iter[Num_abnormal-n_exp:] # Indexes for randomly selected Abnormal Videos

TypeError: slice indices must be integers or None or have an index method

It seems to be same problem because of n_exp variable is float, I converted it to integer.