File size: 1,057 Bytes
c1b3a0c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
47
48
49
from ultralytics import YOLO
import cv2

# Load the YOLO model
model = YOLO("make.pt")

# Define the mapping of class indices to car types
class_map = {
0: 'beige',
1: 'black',
2: 'blue',
3: 'brown',
4: 'gold',
5: 'green',
6: 'grey',
7: 'orange',
8: 'pink', 
9: 'purple',
10: 'red',
11: 'sivler',
12: 'tan',
13: 'white',
14: 'yellow'
}
# Open the video file
video_path = 'DATA\greencar.png'
result = model(video_path)

# cap = cv2.VideoCapture(video_path)

# while True:
#     ret, frame = cap.read()
#     if not ret:
#         break

#     # Perform object detection
#     results = model(frame)
    
#     # Assuming the top prediction is what you're interested in
#     top_prediction_index = results[0].probs.top5[0]  # Index of the highest probability class
#     top_prediction_prob = results[0].probs.top5conf[0].item()  # Highest probability

#     # Get the car type from the class_map
#     # car_type = class_map[top_prediction_index]
#     print('/n')
#     print(f"{class_map[top_prediction_index]}")

# cap.release()
# cv2.destroyAllWindows()