NovaIZ commited on
Commit
774d622
·
1 Parent(s): d1eb7e5

added changes to app.py and model.py

Browse files
Files changed (3) hide show
  1. app.py +5 -5
  2. model.py +15 -15
  3. requirements.txt +2 -0
app.py CHANGED
@@ -2,20 +2,20 @@ import gradio as gr
2
  from PIL import Image
3
  import cv2
4
  from ultralytics import YOLO
 
 
5
 
6
- # Load model (ensure the path to the weights file is correct)
7
  model_path = "car_logos.pt"
8
  detection_model = YOLO(model_path)
9
 
10
  def predict_image(pil_image):
11
  """Process an image and return the annotated image."""
12
- # Convert PIL image to NumPy array
13
  frame = cv2.cvtColor(np.array(pil_image), cv2.COLOR_RGB2BGR)
14
 
15
- # Run YOLO model
16
  results = detection_model.predict(frame, conf=0.5, iou=0.6)
17
 
18
- # Annotate the image
19
  annotated_frame = results[0].plot()
20
 
21
 
@@ -59,7 +59,7 @@ def create_gradio_interface():
59
  image_button = gr.Button("Process Image")
60
  image_button.click(fn=predict_image, inputs=image_input, outputs=image_output)
61
 
62
- with gr.Tab("Video Upload"):
63
  gr.Markdown("### Upload a Video for Object Detection")
64
  video_input = gr.Video(label="Input Video")
65
  video_output = gr.File(label="Annotated Video")
 
2
  from PIL import Image
3
  import cv2
4
  from ultralytics import YOLO
5
+ import numpy as np
6
+
7
 
 
8
  model_path = "car_logos.pt"
9
  detection_model = YOLO(model_path)
10
 
11
  def predict_image(pil_image):
12
  """Process an image and return the annotated image."""
13
+
14
  frame = cv2.cvtColor(np.array(pil_image), cv2.COLOR_RGB2BGR)
15
 
16
+
17
  results = detection_model.predict(frame, conf=0.5, iou=0.6)
18
 
 
19
  annotated_frame = results[0].plot()
20
 
21
 
 
59
  image_button = gr.Button("Process Image")
60
  image_button.click(fn=predict_image, inputs=image_input, outputs=image_output)
61
 
62
+ with gr.Tab("Video Upload for Toyota and Honda logo detection"):
63
  gr.Markdown("### Upload a Video for Object Detection")
64
  video_input = gr.Video(label="Input Video")
65
  video_output = gr.File(label="Annotated Video")
model.py CHANGED
@@ -14,21 +14,21 @@ settings.update({"wandb": True,
14
 
15
 
16
  model = YOLO("yolov8s.pt")
17
- # result = model.train(data="220180T_carlogos-5/data.yaml",
18
- # epochs=30,
19
- # save_period=1,
20
- # batch=50,
21
- # device= "cpu",
22
- # project='Car-Logos',
23
- # plots=True,
24
- # freeze=5,
25
- # lr0= 1e-7,
26
- # optimizer = "Adam" ,
27
- # cls = 0.1,
28
- # )
29
-
30
-
31
- model = YOLO("Car-Logos/train17/weights/best.pt")
32
  validation_results = model.val(data="220180T_carlogos.v5i.yolov8-obb/data.yaml", device="cpu")
33
 
34
  model.save("car_logos.pt")
 
14
 
15
 
16
  model = YOLO("yolov8s.pt")
17
+ result = model.train(data="220180T_carlogos-5/data.yaml",
18
+ epochs=30,
19
+ save_period=1,
20
+ batch=50,
21
+ device= "cpu",
22
+ project='Car-Logos',
23
+ plots=True,
24
+ freeze=5,
25
+ lr0= 1e-7,
26
+ optimizer = "Adam" ,
27
+ cls = 0.1,
28
+ )
29
+
30
+
31
+ model = YOLO("car_logos.pt")
32
  validation_results = model.val(data="220180T_carlogos.v5i.yolov8-obb/data.yaml", device="cpu")
33
 
34
  model.save("car_logos.pt")
requirements.txt CHANGED
@@ -1,2 +1,4 @@
1
  ultralytics
2
  huggingface_hub
 
 
 
1
  ultralytics
2
  huggingface_hub
3
+ wandb
4
+ roboflow