A simple Wrapper for YOLOv7
Project description
An unofficial wrapper of the yolov7 project.
It is very simple, and has only one function: calculateDetections()
.
Currently it only supports images, on CPU.
Installation
The package is hosted on pypi, so you can install it with pip:
pip install YOLOv7Detector
Usage
You must download a model from the yolov7 project page, and place it in the root directory of this project. Then you can use the following code to run inference on an image:
from YOLOv7Detector import Detector as det
from PIL import Image
def main():
# Initialize the YOLO inference object
detector = det(weights_path='yolov7.pt', conf_thres=0.7, iou_thres=0.45, img_size=640)
# Load the image
image = Image.open('test_images/test_4.jpg')
download_path = 'test_images/test_4_result.jpg' # Leave as None if not needed
dets = detector.calculateDetections(image, view_img=True, download_path=download_path)
print(dets)
if __name__ == '__main__':
main()
This returns a list of dictionaries, each dictionary is formatted as follows:
{
'class': 'person',
'confidence': 0.966009259223938,
'bbox': [31.0, 144.0, 469.0, 653.0]
}
where bbox
is a list of [x1, y1, x2, y2]
coordinates of the bounding box.
With view_img=True
, the image with bounding boxes will be displayed as such:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file YOLOv7Detector-0.0.4.tar.gz
.
File metadata
- Download URL: YOLOv7Detector-0.0.4.tar.gz
- Upload date:
- Size: 139.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3452f3d9cda7564dddffbf984fc8770cdf2d0b5c11cb62b367d83e3d5d3d7577 |
|
MD5 | f9a7b5d330baf9d16f0e695d41eb6e71 |
|
BLAKE2b-256 | 8f6de3b9a4e88f77dc6c0aabd36c9fe29eb90fa1eb7f8e3026c51195f5d1d4ec |
File details
Details for the file YOLOv7Detector-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: YOLOv7Detector-0.0.4-py3-none-any.whl
- Upload date:
- Size: 152.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2915c0bfeb101220aa81107e7bddc1ec22ae222db99ea272d7df17621f124cde |
|
MD5 | d957e2539aed6f28c96220a8164f733e |
|
BLAKE2b-256 | 603e1ed607223733f5f45b540d7fd21db3ed759b910daf1b00b4a646d510c79a |