-
Notifications
You must be signed in to change notification settings - Fork 0
/
Visualizer.py
31 lines (26 loc) · 1.04 KB
/
Visualizer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import shutil
from PIL import Image
from ultralytics import YOLO
import subprocess
if __name__ == '__main__':
best_model_path = "runs/detect_yolo8_bbox_no_test/train/weights/best.pt"
file_name = 'ave-0058-0013'
image_path = file_name + '.jpg'
target_path = 'data/images/' + image_path
model = YOLO(best_model_path)
inference = model(target_path, visualize=True)#, save=True, save_crop=True
'''
results = model(target_path) # , conf=.1)
shutil.copy(target_path, "target.jpg")
'''
for data in inference:
im_array = data.plot()
im = Image.fromarray(im_array[..., ::-1])
im.show()
im.save('output_evaluation/result.jpg')
print("img saved!")
#--dataset CropOrWeed2 --filter ave-0058-0013
#subprocess.call(["python", "cnw/visualize_annotations.py", "--dataset", "CropOrWeed2", "--filter", file_name])
print("Da confrontare risultati presenti in cartella output-evaluation")
# https://www.youtube.com/watch?v=dVE0THUbPH4
#https://www.youtube.com/watch?v=Z-65nqxUdl4