Closed tyseng92 closed 3 years ago
If you haven't done anything other than modifying the number of classes,
from yolov4.tf import YOLOv4
yolo = YOLOv4()
yolo.classes = r"c:/Users/win/Downloads/coco17.names"
yolo.make_model()
yolo.load_weights(r"c:/Users/win/Downloads/yolov4-custom_36cls_70000.weights", weights_type="yolo")
yolo.inference(0, is_image=False)
I tested the above script with cam.
Thanks for the testing. I have tested the name and weight files on my code which is similar to your, but it seems cannot detected the new class called 'lozenges'. Here is the sample image of the lozenges. Just wonder if the problem comes from the absence of the yolov4-custom.cfg config file. Note that the class number is 36 and the filter size is 123. Should I set the yolo.input_size = 416 yolo.batch_size = 64
as well to match the config file? Thanks.
from yolov4.tf import YOLOv4
yolo = YOLOv4()
yolo.classes = r"c:/Users/win/Downloads/coco17.names"
yolo.make_model()
yolo.load_weights(r"c:/Users/win/Downloads/yolov4-custom_36cls_70000.weights", weights_type="yolo")
yolo.inference(media_path=r"c:/Users/win/Downloads/silo-50836376-front-287098_400Wx400H.jfif")
:)
I have solved my problem on my side too. Thanks for your verification.
I was trying to train a new custom detector by adding one additional new class object into the reduced COCO dataset (1 new class + 35 classes). And I have trained new weight file using yolov4.conv.137 with modified yolov4-custom.cfg from Darknet AlexeyAB. Is there any way to add my yolov4-custom.cfg into your code so that the detector could identify the new object? Thanks.