LongxingTan / tfyolo

tfyolo: Efficient Implementation of Yolov5 in TensorFlow
229 stars 71 forks source link

detect wrong #7

Open Superman0307 opened 3 years ago

Superman0307 commented 3 years ago

After finishing train 100 epoch with voc dataset,I detect the train sample.but It's find nothing . the Loss about 500.

kalikhademi commented 3 years ago

I have the same issue. I train without any problem with loss around 200 but when I run detect.py it shows the message no box detected which means there is not bbox detected. Were you able to figure this out @LongxingTan ?

AI-Passionner commented 3 years ago

I had the same issue, using the pre-trained model (converted from pytorch). In the detect.py, there might be something wrong with pred_bbox. I am debugging now.

AI-Passionner commented 3 years ago

Figured it out. It seems that the detect.py has some bugs there. The model was yolo5s, converted from the Ultralytics yolo5. What I did are following:

  1. comment out the next two lines. If you check the function batch_non_max_suppression(). Those variable definitions are not consistent.

    pred_bbix = [tf.reshape(x , ...]

    pred_bbox = tf.concat(pred_bbox, ...)

  2. The predictions of bbox are [0, 1]. We need to re-scale back to the image input size, for example, 640x640 (depending on your training model). I added two lines before calling the resize_back(). bboxes[:, [0,2]] = bboxes[:, [0,2]] 640 bboxes[:, [1,3]] = bboxes[:, [1,3]] 640

Then it fixed the problem of no box detected. Hopefully, this is helpful.