Python

Image Detection with YOLO-v2 (pt.2) Process Image in Python + openCV



In this series we will explore the capabilities of YOLO for image detection in python!

This video will look at
– how to process images with YOLO in python
– how display the image and add the bounding box plus label

Github Slides:
Install Anaconda:
Install Tensorflow:
windows…

Similar Posts

33 thoughts on “Image Detection with YOLO-v2 (pt.2) Process Image in Python + openCV
  1. Hi Mark
    The problem of the yolov2.weights has been pointed out by some peoples in the comment.
    Can you share us your yolo.weights so that we don't encounter the
    AssertionError: bin/yolov2.weights not found ?
    This file has been replaced by yolov2.weights and it may cause the problem
    Or maybe the build after creating the bin is not taken into account ?
    Thank you

  2. Thanks dear mark !!! may i know what's my problem below here?
    import cv2

    from darkflow.net.build import TFNet

    ModuleNotFoundError Traceback (most recent call last)

    <ipython-input-9-ea3a6c0f49c0> in <module>

    1 import cv2

    —-> 2 from darkflow.net.build import TFNet

    C:forsakendarkflow-masterdarkflownetbuild.py in <module>

    3 from . import help

    4 from . import flow

    —-> 5 from .ops import op_create, identity

    6 from .ops import HEADER, LINE

    7 from .framework import create_framework

    C:forsakendarkflow-masterdarkflownetops__init__.py in <module>

    —-> 1 from .simple import *

    2 from .convolution import *

    3 from .baseop import HEADER, LINE

    4

    5 op_types = {

    C:forsakendarkflow-masterdarkflownetopssimple.py in <module>

    —-> 1 import tensorflow.contrib.slim as slim

    2 from .baseop import BaseOp

    3 import tensorflow as tf

    4 from distutils.version import StrictVersion

    5

    ModuleNotFoundError: No module named 'tensorflow.contrib.slim'

  3. I am getting this error:

    Traceback (most recent call last):
    File "project_2.py", line 17, in <module>
    result=TFNet.return_predict(images)
    TypeError: return_predict() missing 1 required positional argument: 'im'

  4. Great tutorial! Just a small comment though. When I used the same doge image (with different dimensions), my code gave me a result with several labels (including bed, person, and other stuff with really low confidence values), but "dog" had the highest confidence value, and it wasn't the first on the list. In this case, when we want to plot the bounding box, using result[0] is not the correct thing to do. Instead, we should obtain the result with the maximum confidence before that, and then just use its x and y directly to plot the bounding box.

    Edit: when I ran the code before flipping the channels, the result was dog with 0.6 confidence. After flipping them, the result went lower to 0.44. Interesting..

  5. I am getting the following error…any idea why??

    —————————————————————————

    error Traceback (most recent call last)

    <ipython-input-8-4e54273e1abd> in <module>()

    1 img=cv2.imread('Purple-dragon', cv2.IMREAD_COLOR)

    —-> 2 img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

    3 result=tfnet.return_predict(img)

    error: OpenCV(3.4.3) /io/opencv/modules/imgproc/src/color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

  6. tl = (result[0]['topleft']['x'], result[0]['topleft']['y'])

    3 br = (result[0]['bottomright']['x'], result[0]['bottomright']['y'])

    4 label = result[0]['label']

    5

    IndexError: list index out of range getting this error after running the
    tl = (result[0]['topleft']['x'], result[0]['topleft']['y'])

    br = (result[0]['bottomright']['x'], result[0]['bottomright']['y'])

    label = result[0]['label']

  7. I'm not able to use the GPU version of this as I am ending up with an error.
    I.e.
    2018-11-09 17:22:59.204168: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4046 MB memory) -> physical GPU (device: 0, name: GeForce 940MX, pci bus id: 0000:01:00.0, compute capability: 5.0)
    2018-11-09 17:23:08.644548: E tensorflow/stream_executor/cuda/cuda_dnn.cc:373] Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
    2018-11-09 17:23:08.662696: E tensorflow/stream_executor/cuda/cuda_dnn.cc:373] Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
    2018-11-09 17:23:27.752879: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0
    2018-11-09 17:23:27.752936: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix:
    2018-11-09 17:23:27.752947: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988] 0

    To use it I have to comment out the gpu part in options.
    Any solutions for this?

  8. It is showing me this error
    ModuleNotFoundError Traceback (most recent call last)

    <ipython-input-1-17de757420c4> in <module>

    1 import cv2

    —-> 2 from darkflow.net.build import TFNet

    3 import matplotlib.pyplot as plt

    4

    5 get_ipython().run_line_magic('config', "InlineBackend.figure_format = 'svg'")

    ModuleNotFoundError: No module named 'darkflow'

  9. I'm stuck at minute 5:00. I overcome the first two FileNotFoundError by writing the weights and cfg documents absolut paths, but I don't know how to go about this error: FileNotFoundError: [Errno 2] No such file or directory: './cfg/coco.names'. As it occurs while executing the code, I can't explicitly write the path of that file . Anyone at the same point?

  10. While converting image to RGB (cv2.cvtColor(img, cv2.COLOR_BGR2RGB)) I am getting the following error:

    error: /build/opencv-SviWsf/opencv-2.4.9.1+dfsg/modules/imgproc/src/color.cpp:3648: error: (-215) scn == 3 || scn == 4 in function cvtColor

    However, I tried your first video tutorial it went awesome. Any clues for the above error!

Leave a Reply

Your email address will not be published. Required fields are marked *