balancap / SSD-Tensorflow

Single Shot MultiBox Detector in TensorFlow
4.11k stars 1.89k forks source link

Running SSD in latest Tensorflow #321

Open rabbitwayne opened 5 years ago

rabbitwayne commented 5 years ago

I tried to run SSD using the latest Tensorflow >= r1.12 and had a lot of issues. Wonder will support of latest Tensorflow be added in the future?

I tried to run inference with the following command: python eval_ssd_network.py \ --eval_dir=${EVAL_DIR} \ --dataset_dir=${DATASET_DIR} \ --dataset_name=pascalvoc_2007 \ --dataset_split_name=test \ --model_name=ssd_300_vgg \ --checkpoint_path=${CHECKPOINT_PATH} \ --batch_size=8 but got the following error

Traceback (most recent call last): File "eval_ssd_network.py", line 360, in tf.app.run() File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "eval_ssd_network.py", line 248, in main tp_fp_metric = tfe.streaming_tp_fp_arrays(num_gbboxes, tp, fp, rscores) File "/data/SSD/tf_extended/metrics.py", line 151, in streaming_tp_fp_arrays name=scope) File "/data/SSD/tf_extended/metrics.py", line 178, in streaming_tp_fp_arrays v_nobjects = _create_local('v_num_gbboxes', shape=[], dtype=tf.int64) File "/data/SSD/tf_extended/metrics.py", line 56, in _create_local validate_shape=validate_shape) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/variables.py", line 185, in call return cls._variable_v2_call(*args, **kwargs) TypeError: _variable_v2_call() got an unexpected keyword argument 'collections'

Then I changed line 51 in /data/SSD/tf_extended/metrics.py to return variables.VariableV1( , the above error went away, but the script exits without actually running inference. Any hint on this problem? Thanks!

xiyuanzh commented 5 years ago

@rabbitwayne Hello! I have met the same problem. Have you solved it? Thanks a lot!

bygreencn commented 5 years ago

sorry, my mistake to not show you all information:

  1. used 1.13rc1,
  2. change tf_extended/metrics.py line 51 to variables.VariableV1
  3. add a function

def flatten(x): result = [] for el in x: if isinstance(el, tuple): result.extend(flatten(el)) else: result.append(el) return result

and flatten the parameter of slim.evaluation.evaluate_once as "eval_op=flatten(list(names_to_updates.values())),"

xiyuanzh commented 5 years ago

@bygreencn That helps! Thanks a lot!!

Sulince commented 5 years ago

1、I changed the tf_extended/metrics.py line 51 to variables.VariableV1 2、you mean where to add a function? in eval_ssd_network.py??? @bygreencn @xiyuanzh

Sulince commented 5 years ago

can you tell me your tf version?? @bygreencn @xiyuanzh

xiyuanzh commented 5 years ago

@Sulince Yes, in eval_ssd_network.py. My version is r1.12. Now I can run the evaluation code but get a mAP of 0. #221 states the same problem with me. It seems to have something to do with the flatten fuction and I haven't found out the solution. If you can sucessfully get the result, could you please help me with it? @bygreencn @rabbitwayne Have you met the same problem of 0 mAP before? This is the output of the flatten fuction:

[<tf.Tensor 'mean/update_op:0' shape=() dtype=float32>, <tf.Tensor 'mean_1/update_op:0' shape=() dtype=float32>, <tf.Tensor 'mean_2/update_op:0' shape=() dtype=float32>, <tf.Tensor 'streaming_tp_fp_1/AssignAdd:0' shape=() dtype=int64_ref>, <tf.Tensor 'streaming_tp_fp_1/AssignAdd_1:0' shape=() dtype=int32_ref>, <tf.Tensor 'streaming_tp_fp_1/Assign_1:0' shape=(?,) dtype=bool_ref>, <tf.Tensor 'streaming_tp_fp_1/Assign_2:0' shape=(?,) dtype=bool_ref>, <tf.Tensor 'streaming_tp_fp_1/Assign:0' shape=(?,) dtype=float32_ref>]

I need your help!! Thanks a lot!!

Sulince commented 5 years ago

I have run eval_ssd_network.py succefully, but i got the same problem that the mAP is very low ,just like the result you had got . I got no idea to solve it. Have you solve it yet??? @xiyuanzh if you solve it, help me! please! contact me at 15215420373@163.com

xiyuanzh commented 5 years ago

@Sulince Hello, have you solved the problem? I tried to contact you but the email address does not exist.

Sulince commented 5 years ago

@xiyuanzh sorry, i give the wrong address, i have correct it . and i have solved the problem. see at @ #264

xinkai-jiang commented 5 years ago

sorry, my mistake to not show you all information:

  1. used 1.13rc1,
  2. change tf_extended/metrics.py line 51 to variables.VariableV1
  3. add a function

def flatten(x): result = [] for el in x: if isinstance(el, tuple): result.extend(flatten(el)) else: result.append(el) return result

and flatten the parameter of slim.evaluation.evaluate_once as "eval_op=flatten(list(names_to_updates.values())),"

sorry, but I cannot find "eval_op=flatten(list(names_to_updates.values()))," . could you tell me what py file can find it in?

mathuse commented 5 years ago

I have run eval_ssd_network.py succefully, but i got the same problem that the mAP is very low ,just like the result you had got . I got no idea to solve it. Have you solve it yet??? @xiyuanzh if you solve it, help me! please! contact me at 15215420373@163.com

Can you tell me the version of python and tensorflow? I need a right and proper environment,thanks.

shijunnn commented 4 years ago

Hi @Sulince @xiyuanzh , did you guys managed to solve the issue of getting 0 mAP? If yes, could you enlighten on how did you guys solve it?

INFO:tensorflow:Evaluation [963/9634] I0803 12:24:58.229241 9844 evaluation.py:167] Evaluation [963/9634] INFO:tensorflow:Evaluation [1926/9634] I0803 12:27:41.523166 9844 evaluation.py:167] Evaluation [1926/9634] INFO:tensorflow:Evaluation [2889/9634] I0803 12:30:22.842613 9844 evaluation.py:167] Evaluation [2889/9634] INFO:tensorflow:Evaluation [3852/9634] I0803 12:33:05.738677 9844 evaluation.py:167] Evaluation [3852/9634] INFO:tensorflow:Evaluation [4815/9634] I0803 12:35:47.935612 9844 evaluation.py:167] Evaluation [4815/9634] INFO:tensorflow:Evaluation [5778/9634] I0803 12:38:28.797521 9844 evaluation.py:167] Evaluation [5778/9634] INFO:tensorflow:Evaluation [6741/9634] I0803 12:41:10.568399 9844 evaluation.py:167] Evaluation [6741/9634] INFO:tensorflow:Evaluation [7704/9634] I0803 12:43:52.274564 9844 evaluation.py:167] Evaluation [7704/9634] INFO:tensorflow:Evaluation [8667/9634] I0803 12:46:36.202533 9844 evaluation.py:167] Evaluation [8667/9634] INFO:tensorflow:Evaluation [9630/9634] I0803 12:49:18.376631 9844 evaluation.py:167] Evaluation [9630/9634] INFO:tensorflow:Evaluation [9634/9634] I0803 12:49:19.001646 9844 evaluation.py:167] Evaluation [9634/9634] AP_VOC07/mAP[0] AP_VOC12/mAP[0] INFO:tensorflow:Finished evaluation at 2020-08-03-12:49:26 I0803 12:49:26.129172 9844 evaluation.py:275] Finished evaluation at 2020-08-03-12:49:26 Time spent : 1694.618 seconds. Time spent per BATCH: 0.176 seconds.