Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After single-class training, nothing can be detected. #126

Closed
MarkDana opened this issue Mar 13, 2019 · 5 comments
Closed

After single-class training, nothing can be detected. #126

MarkDana opened this issue Mar 13, 2019 · 5 comments

Comments

@MarkDana
Copy link

I've used this model to train for a single-class dataset, which contains 300 images. After 500 epochs of training, total loss has been reduced to a fairly low level (min=0.011), with precision up to 0.887.

However when I use the generated weights to detect images in the train-val set, nothing can be detected for each image. When running detect.py,

detections = model(input_imgs)
detections = non_max_suppression(detections, 1, opt.conf_thres, opt.nms_thres)
print(detections)

All images show [None].

Below is some changes I made to the original project:

  • 1.in yolov3.cfg,
batch=16
subdivisions=4
filters=18(you know where..)
classes=1
  • 2.in detect.py, to test the probability, I edited non_max_suppression(detections, num_classes=1, opt.conf_thres=0, opt.nms_thres=0), but nothing detected, still.

One of the reason may be that, the weights were initialized from yolov9.weights, and that may be different in network structure I edited in yolov3.cfg.

What's more, exploding gradient problem happened 3 times in the 500 epochs.

Anyone in same situation or can help me? thks.

@fourth-archive
Copy link

@MarkDana try this tutorial.
https://github.com/ultralytics/yolov3/wiki/Example:-Train-Single-Class

The https://github.com/ultralytics/yolov3 repository also includes a YOLOv3 realtime iPhone app:

@MarkDana
Copy link
Author

@MarkDana try this tutorial.
https://github.com/ultralytics/yolov3/wiki/Example:-Train-Single-Class

The https://github.com/ultralytics/yolov3 repository also includes a YOLOv3 realtime iPhone app:

Thks and I've tried this tutorial. Training now, waiting to see the result.
What's more, the two bugs mentioned in issue127 also work for me.

@gfjiangly
Copy link

gfjiangly commented Mar 14, 2019

I had same questiones with me before.
I think the reason is that "save_weights" function in trian.py doesn't match "load_weights" function in detect.py. You can replace
model.apply(weights_init_normal) with
model.apply(weights_init_normal)
model.load_state_dict(torch.load(opt.weights_path))
and replace
model.save_weights("%s/%d.weights" % (opt.checkpoint_dir, epoch)) with
torch.save(model.state_dict(), "%s/%d.weights" % (opt.checkpoint_dir, epoch)) in train.py.

in detect.py, replace
model.load_weights(opt.weights_path) with
model.load_state_dict(torch.load(opt.weights_path))

@0merjavaid
Copy link

Use transfer learning as mentioned by @gfjiangly it wont show results otherwise

@MarkDana
Copy link
Author

Both @gfjiangly and @fourth-archive 's method work well. I'll close this issue, thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants