-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevaluation.py
46 lines (33 loc) · 993 Bytes
/
evaluation.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
import shutil
import valohai
from ultralytics import YOLO
def save_to_outputs():
print("Saving to Valohai")
path = "runs/detect/val"
save_path = valohai.outputs("detections")
for f in os.listdir(path):
src = os.path.join(path, f)
dst = save_path.path(f)
shutil.copy(src, dst)
def evaluate_yolo():
# Load a model
model_path = valohai.inputs("model").path()
model = YOLO(model_path) # load our model
# Validate the model
metrics = model.val(
data="/valohai/inputs/data_yaml/data.yaml",
split="test",
plots=True,
)
print("Results: ")
print("map50-95", metrics.box.map) # map50-95
print("map50", metrics.box.map50) # map50
print("map75", metrics.box.map75) # map75
print(
"List map50-95 of each category: ",
metrics.box.maps,
) # a list contains map50-95 of each category
save_to_outputs()
if __name__ == "__main__":
evaluate_yolo()