Spaces:
Sleeping
Sleeping

feat: add complete pipeline and Streamlit code This commit introduces a complete pipeline for both single and real-time inferences using cameras. It includes the implementation of Streamlit code to facilitate the process.
c640bc9
verified
import os | |
import time | |
from pathlib import Path | |
from ultralytics import YOLO | |
class DetectionService: | |
def __init__(self, model_path): | |
self.model_path = model_path | |
def image_det_save(self, image_path, thresh=0.2): | |
""" | |
image detection and save the image with bounding box | |
:param image_path: | |
:param thresh: | |
:return: | |
""" | |
detector = YOLO(self.model_path) | |
results = detector.predict(image_path, conf=thresh, show=False) | |
return results | |
if __name__ == "__main__": | |
detection_service = DetectionService( | |
model_path='resources/models/v1/best.pt', | |
) | |
input_image_path = Path( | |
"/home/ishwor/Downloads/PY-4856_Crosman-Bushmaster-MPW-Full_1558033480-458822316.jpg") | |
detection_service.image_det_save( | |
image_path=str(input_image_path), | |
thresh=0.2 | |
) | |