Skip to main content

Python wrapper on YOLO 3.0 implementation by 'pjreddie': (https://pjreddie.com/yolo)

Project description

A Python wrapper on pjreddie's implementation (authors' implementation) of YOLO V3 Object Detector on Darknet. This wrapper is also compatible with other Darknet object detection models.

OutputImage Image source: http://absfreepic.com/free-photos/download/crowded-cars-on-street-4032x2272_48736.html

Prerequisites

  • Python 3.6+
  • Linux x86-64 Operating System
  • NVIDIA CUDA SDK (for GPU version only. Make sure nvcc is available in PATH variable.)

Sample Usage

Note: This sample code requires OpenCV with python bindings installed. (pip3 install opencv-python==3.4.0)

  1. Create a directory to host sample code and navigate to it.
  2. Download and execute this script to download model files.
  3. Create sampleApp.py with following code. Specify SAMPLE_INPUT_IMAGE.
    from pydarknet import Detector, Image
    import cv2
    
    net = Detector(bytes("cfg/yolov3.cfg", encoding="utf-8"), bytes("weights/yolov3.weights", encoding="utf-8"), 0, bytes("cfg/coco.data",encoding="utf-8"))
    
    img = cv2.imread('SAMPLE_INPUT_IMAGE')
    img_darknet = Image(img)
    
    results = net.detect(img_darknet)
        
    for category, score, bounds in results:
        x, y, w, h = bounds
        cv2.rectangle(img, (int(x - w / 2), int(y - h / 2)), (int(x + w / 2), int(y + h / 2)), (255, 0, 0), thickness=2)
        cv2.putText(img, category ,(int(x),int(y)),cv2.FONT_HERSHEY_COMPLEX,1,(255,255,0))
    
    cv2.imshow("output", img)
    cv2.waitKey(0)
    
  4. Execute sampleApp.py python sampleApp.py.

Installation

yolo34py comes in 2 variants, CPU Only Version and GPU Version. Installation may take a while since it involves downloading and compiling darknet.

CPU Only Version

This version is configured on darknet compiled with flag GPU = 0.

pip3 install requests # Used to download darknet
pip3 install cython
pip3 install numpy
pip3 install yolo34py

GPU Version:

This version is configured on darknet compiled with flag GPU = 1.

pip3 install requests # Used to download darknet
pip3 install cython
pip3 install numpy
pip3 install yolo34py-gpu

More Information

License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yolo34py-gpu-0.2.tar.gz (67.9 kB view details)

Uploaded Source

File details

Details for the file yolo34py-gpu-0.2.tar.gz.

File metadata

  • Download URL: yolo34py-gpu-0.2.tar.gz
  • Upload date:
  • Size: 67.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10

File hashes

Hashes for yolo34py-gpu-0.2.tar.gz
Algorithm Hash digest
SHA256 fcabdf59645e532d844f11d28bc0926868543cd02ba8d32970aee14be69fee51
MD5 59d1a51fcce5a797cd0e2758e2d38d09
BLAKE2b-256 c960e408d48165b9198fc9c0af40399f0dd56602a81dd7a9115b9473b54198e9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page