Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,14 +8,14 @@ from ultralytics import YOLO
|
|
8 |
model = YOLO('best.pt')
|
9 |
|
10 |
# Function for image processing
|
11 |
-
def
|
12 |
image = cv2.imread(image_path)
|
13 |
results = model.predict(source=image_path)
|
14 |
annotated_image = results[0].plot()
|
15 |
return cv2.cvtColor(annotated_image, cv2.COLOR_BGR2RGB)
|
16 |
|
17 |
# Function for video processing
|
18 |
-
def
|
19 |
cap = cv2.VideoCapture(video_path)
|
20 |
out_frames = []
|
21 |
fps = int(cap.get(cv2.CAP_PROP_FPS))
|
@@ -42,21 +42,21 @@ def show_preds_video(video_path):
|
|
42 |
inputs_image = gr.Image(type="filepath", label="Input Image")
|
43 |
outputs_image = gr.Image(type="numpy", label="Output Image")
|
44 |
interface_image = gr.Interface(
|
45 |
-
fn=
|
46 |
inputs=inputs_image,
|
47 |
outputs=outputs_image,
|
48 |
title="ITI107 Assignment - 4744695Y",
|
49 |
-
description="Taxi & License Plate Detection
|
50 |
)
|
51 |
|
52 |
inputs_video = gr.Video(label="Input Video")
|
53 |
outputs_video = gr.Video(label="Annotated Output")
|
54 |
interface_video = gr.Interface(
|
55 |
-
fn=
|
56 |
inputs=inputs_video,
|
57 |
outputs=outputs_video,
|
58 |
title="ITI107 Assignment - 4744695Y",
|
59 |
-
description="Taxi & License Plate Detection
|
60 |
)
|
61 |
|
62 |
gr.TabbedInterface(
|
|
|
8 |
model = YOLO('best.pt')
|
9 |
|
10 |
# Function for image processing
|
11 |
+
def show_det_image(image_path):
|
12 |
image = cv2.imread(image_path)
|
13 |
results = model.predict(source=image_path)
|
14 |
annotated_image = results[0].plot()
|
15 |
return cv2.cvtColor(annotated_image, cv2.COLOR_BGR2RGB)
|
16 |
|
17 |
# Function for video processing
|
18 |
+
def show_det_video(video_path):
|
19 |
cap = cv2.VideoCapture(video_path)
|
20 |
out_frames = []
|
21 |
fps = int(cap.get(cv2.CAP_PROP_FPS))
|
|
|
42 |
inputs_image = gr.Image(type="filepath", label="Input Image")
|
43 |
outputs_image = gr.Image(type="numpy", label="Output Image")
|
44 |
interface_image = gr.Interface(
|
45 |
+
fn=show_det_image,
|
46 |
inputs=inputs_image,
|
47 |
outputs=outputs_image,
|
48 |
title="ITI107 Assignment - 4744695Y",
|
49 |
+
description="Taxi & License Plate Detection using YOLOv8"
|
50 |
)
|
51 |
|
52 |
inputs_video = gr.Video(label="Input Video")
|
53 |
outputs_video = gr.Video(label="Annotated Output")
|
54 |
interface_video = gr.Interface(
|
55 |
+
fn=show_det_video,
|
56 |
inputs=inputs_video,
|
57 |
outputs=outputs_video,
|
58 |
title="ITI107 Assignment - 4744695Y",
|
59 |
+
description="Taxi & License Plate Detection using YOLOv8"
|
60 |
)
|
61 |
|
62 |
gr.TabbedInterface(
|