[3f73f3]: / MODEL / Testing.py

Download this file

24 lines (18 with data), 593 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import cv2
import numpy as np
from ultralytics import YOLO
# Load the YOLOv8 model
model = YOLO('best_75.pt')
# Load the image
image = cv2.imread('D:\CSE\Semester - 5\Extra\IIT jammu\YOLO\Code\Test_Dataset\Test_Dataset_2\A0484.png')
# Perform inference
# results = model.predict(image, show=True, save=True)
results = model.predict(image, show=True)
# Check if the image is bleeding
if results[0].boxes.shape[0] > 0:
print('Bleeding Frame')
# Print the bounded boxes
for box in results[0].boxes:
print(box)
else:
print('Non-Bleeding Frame')