I am using the below code to load the trained custom Yolov5 model and perform detections.
import cv2
import torch
from PIL import Image
model = torch.hub.load('ultralytics/yolov5', 'custom',
path='yolov5/runs/train/exp4/weights/best.pt', force_reload=True)
img = cv2.imread('example.jpeg')[:, :, ::-1] # OpenCV image (BGR to RGB)
results = model(img, size=416)
#To display and save results I am using:
results.print()
results.save()
results.show()
My question is how can I save the results in different directory so that I can use them in my web-based application. For your reference I am using Streamlit. For instance, at the moment, results (image) are being saved in runs\detect\exp*. I want to change it. Can anyone please guide me.