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
Hashes for YOLOv7Detector-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93caad6561430b64e44916fc56a1d41c612a4637bf215985d947639d8463a14d |
|
MD5 | d62c0d6260470caa907114c9d1952379 |
|
BLAKE2b-256 | 468f1d44eeac7f520ebb727bc6ec6e4c8f854f53e7390f46c2b0dbac8261aab3 |