Python Wrapper for the YOLO
Installation
Dependencies
- Linux
- Python >= 3.6
- Darknet Shared Library
- numpy
- OpenCV
Darknet Shared Library
You should first install darknet
library with BUILD_SHARED_LIBS set to ON.
After the installation the LIB_DARKNET environment variable should be set to
shared library path. The path is required in runtime so my recommendation is
adding this to your rc file. export LIB_DARKNET=<path_to_libdarknet.so>
PyYOLO
From PyPi
pip3 install pyyolo --user
From source
git clone https://github.com/goktug97/PyYOLO
cd PyYOLO
python3 setup.py install --user
Documentation
Example
python sample.py
import cv2
import pyyolo
def main():
detector = pyyolo.YOLO("./models/yolov3-spp.cfg",
"./models/yolov3-spp.weights",
"./models/coco.data",
detection_threshold = 0.5,
hier_threshold = 0.5,
nms_threshold = 0.45)
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
dets = detector.detect(frame, rgb=False)
for i, det in enumerate(dets):
print(f'Detection: {i}, {det}')
xmin, ymin, xmax, ymax = det.to_xyxy()
cv2.rectangle(frame, (xmin, ymin), (xmax, ymax), (0, 0, 255))
cv2.imshow('cvwindow', frame)
if cv2.waitKey(1) == 27:
break
if __name__ == '__main__':
main()
BBox Class
This class is just a numpy array with extra attributes and functions.
Python 3.8.0 (default, Oct 23 2019, 18:51:26)
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyyolo
>>> bbox = pyyolo.BBox(x=10, y=20, w=100, h=200, prob=0.9, name='person')
>>> bbox
BBox([ 10, 20, 100, 200])
>>> print(bbox)
x: 10, y: 20, w: 100, h: 200, probability: 0.9, name: person
>>> x, y, w, h = bbox
>>> print(x, y, w, h)
10 20 100 200
>>> bbox + bbox
BBox([ 20, 40, 200, 400])
>>> bbox.prob
0.9
>>> bbox.name
'person'
>>> xmin, ymin, xmax, ymax = bbox.to_xyxy()
>>> xmin, ymin, xmax, ymax
(10, 20, 110, 220)
YOLO Class
- detect function returns list of BBox Instances. See sample.py for example usage.
Python 3.8.0 (default, Oct 23 2019, 18:51:26)
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyyolo
>>> detector = pyyolo.YOLO("./models/yolov3-spp.cfg",
"./models/yolov3-spp.weights",
"./models/coco.data",
detection_threshold = 0.5,
hier_threshold = 0.5,
nms_threshold = 0.45)
>>> import cv2
>>> img = cv2.imread('test.png')
>>> detector.detect(img)
[BBox([ 29, 134, 461, 339])]
>>> dets = detector.detect(img)
>>> print(dets[0])
x: 29, y: 134, w: 461, h: 339, probability: 0.6172798275947571, name: person
License
PyYOLO is licensed under the MIT License.
Metadata
Release files for pyyolo 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyyolo-0.1.6.tar.gz | 5.4 kB | Without provenance | Details for pyyolo-0.1.6.tar.gz |
Release files / pyyolo-0.1.6.tar.gz
| Download URL | pyyolo-0.1.6.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a82a2242e1bffa540393cbf6e9f1823de73d23d93a2e5eef2dc335f30cb9e4bc
|
|
BLAKE2b-256 checksum How to use checksums |
f6b90e6e1e136bb5915c3239899483ac8bbf4a23700d0bc82c36ce2fb125d7fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
|
Security for pyyolo 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.