Spaces:
Sleeping
Sleeping
Update iti107_app.py
Browse files- iti107_app.py +19 -0
iti107_app.py
CHANGED
@@ -37,3 +37,22 @@ model_path = "/ITI107-2024S2/9074899G/best_int8_openvino_model"
|
|
37 |
# inputs=gr.Image(type="pil"),
|
38 |
# outputs=gr.Image(type="pil")
|
39 |
# ).launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
# inputs=gr.Image(type="pil"),
|
38 |
# outputs=gr.Image(type="pil")
|
39 |
# ).launch(share=True)
|
40 |
+
|
41 |
+
# source = 'https://raw.githubusercontent.com/nyp-sit/iti107-2024S2/refs/heads/main/session-3/samples/sample_balloon.jpeg'
|
42 |
+
source = './test_pic5.png'
|
43 |
+
model = YOLO("iti107_assignment/train/weights/best_int8_openvino_model", task='detect')
|
44 |
+
result = model(source, conf=0.4, iou=0.4)
|
45 |
+
|
46 |
+
# Visualize the results
|
47 |
+
for i, r in enumerate(result):
|
48 |
+
print(r)
|
49 |
+
# Plot results image
|
50 |
+
im_bgr = r.plot() # BGR-order numpy array
|
51 |
+
im_rgb = Image.fromarray(im_bgr[..., ::-1]) # RGB-order PIL image
|
52 |
+
|
53 |
+
# Show results to screen (in supported environments)
|
54 |
+
r.show()
|
55 |
+
|
56 |
+
# Save results to disk
|
57 |
+
r.save(filename=f"results{i}.png")
|
58 |
+
|