pierluigiferrari / ssd_keras

A Keras port of Single Shot MultiBox Detector
Apache License 2.0
1.86k stars 935 forks source link

ssd7 evaluation -----list index out of range #191

Closed mechealww2 closed 5 years ago

mechealww2 commented 5 years ago

I am trying to train and evaluate the ssd7 on my own datasets,using the code adapt from the ssd300 evaluation code, but i got this error : Producing predictions batch-wise: 100%|██████████| 9/9 [00:17<00:00, 1.91s/it] Matching predictions to ground truth, class 1/5.: 0%| | 0/11 [00:00<?, ?it/s]Traceback (most recent call last): File "C:/Users/lenvov/PycharmProjects/lyk/DIY_robot/ssd_keras/ssd7_evaluate.py", line 196, in verbose=True) File "C:\Users\lenvov\PycharmProjects\lyk\DIY_robot\ssd_keras\eval_utils\average_precision_evaluator.py", line 226, in call self.compute_precision_recall(verbose=verbose, ret=False) File "C:\Users\lenvov\PycharmProjects\lyk\DIY_robot\ssd_keras\eval_utils\average_precision_evaluator.py", line 767, in compute_precision_recall tp = self.cumulative_true_positives[class_id] Matching predictions to ground truth, class 1/5.: 100%|██████████| 11/11 [00:00<00:00, 1849.04it/s] IndexError: list index out of range No predictions for class 2/5 No predictions for class 3/5 No predictions for class 4/5 No predictions for class 5/5 Computing precisions and recalls, class 1/5 Computing precisions and recalls, class 2/5

freekoy commented 5 years ago

Look n_classes ,your dataset have same n_classes? or Look https://github.com/freekoy/comic-textboxs/blob/master/ssd7_evaluation_comic.ipynb

ameyokomori commented 5 years ago

I have the same problem, have you solved yet?

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

karry-yu commented 5 years ago

I meet the same problem, my solution is as follows:

model = load_model('ssd300.h5')
m_input = model.input
m_output = model.output
decoded_predictions = DecodeDetections(confidence_thresh=0.5,
                                        iou_threshold=0.45,
                                        top_k=200,
                                        nms_max_output_size=400,
                                        coords='centroids',
                                        normalize_coords=True,
                                        img_height=300,
                                        img_width=300,
                                        name='decoded_predictions')(m_output)
model = Model(inputs=m_input, outputs=decoded_predictions)

As you see, if you build model using load_model method, in fact the model is saved in training mode, you should set the model to inference mode by adding DecodeDetections layer at the end of the original model.

Hope it helps you!