Skip to content

Object detection sample code does not work with YOLOv3 model #15403

Closed

Description

@rgov
  • OpenCV => 4.1.0
  • Operating System / Platform => macOS 10.14.6
  • Compiler => Python 3
Detailed description

The object_detection.py script barfs when using YOLOv3 weights and config.

Steps to reproduce

Download weights and config:

wget https://pjreddie.com/media/files/yolov3.weights  
wget https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolov3.cfg

Run the example code:

$ python object_detection.py --model yolov3.weights --config yolov3.cfg
Traceback (most recent call last):
  File "object_detection.py", line 71, in <module>
    net = cv.dnn.readNet(cv.samples.findFile(args.model), cv.samples.findFile(args.config), args.framework)
cv2.error: OpenCV(4.1.0) /Users/travis/build/skvark/opencv-python/opencv/modules/dnn/src/darknet/darknet_io.cpp:509: error: (-215:Assertion failed) separator_index < line.size() in function 'ReadDarknetFromCfgStream'

Activity

  1. rgov commented on Aug 27, 2019

    @rgov
    Author

    Config file was damaged. The URLs are corrected above. This works better now.

  2. ManzarIMalik commented on Sep 1, 2019

    @ManzarIMalik

    @rgov, I am having this code error in object detection sample code file. How did you fix this?

    if args.async: line 234 ^ SyntaxError: invalid syntax

  3. rgov commented on Sep 1, 2019

    @rgov
    Author

    @ManzarIMalik My guess is that you are running Python 3.7 or newer, where the async keyword is reserved. You will have to change the variable name used by the sample code, or use an earlier version of the sample code (a few commits back) that does not provide the async feature.

    Please post back if that works.

  4. ManzarIMalik commented on Sep 1, 2019

    @ManzarIMalik

    @rgov, Yes it works now. Thank you :)

  5. zhoujinhai commented on Sep 5, 2019

    @zhoujinhai

    @rgov
    The code is run, but the result is bad, What parameters do you need to adjust?

    python detection.py --input 000035.jpg --model yolov3.weights --config yolov3.cfg --width 416 --height 416 --classes coco_classes.txt
    

    image

  6. zhoujinhai commented on Sep 5, 2019

    @zhoujinhai

    image

  7. rgov commented on Sep 5, 2019

    @rgov
    Author
  8. zhoujinhai commented on Sep 5, 2019

    @zhoujinhai

    @rgov yes, it run well after add --scale, I have an other question that I train my model(model.h5) by qqwweee,then I convert the model's format to model.weights, but the result is so bad, Do you have any good suggestions?

    use-> model.weights model.cfg and classes
    image

    use->model.h5
    image

  9. rgov commented on Sep 6, 2019

    @rgov
    Author

    Sorry @zhoujinhai, I don't know. I suggest posting your question to StackOverflow or https://answers.opencv.org.

  10. zhoujinhai commented on Sep 6, 2019

    @zhoujinhai

    @rgov ok, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions