VlaTal commited on
Commit
0d6882d
1 Parent(s): 807a8fb

fixed colors

Browse files
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -2,6 +2,7 @@ import os
2
  import gradio as gr
3
  from ultralytics import YOLO
4
  import numpy as np
 
5
 
6
  model_options = ["yolo-8n-shiprs.pt", "yolo-8s-shiprs.pt", "yolo-8m-shiprs.pt"]
7
  model_names = ["Nano", "Small", "Medium"]
@@ -18,6 +19,8 @@ def process_image(input_image, model_name, conf):
18
  if conf is None:
19
  conf = 0.6
20
 
 
 
21
  model_index = model_names.index(model_name)
22
  model = models[model_index]
23
 
@@ -28,6 +31,7 @@ def process_image(input_image, model_name, conf):
28
  for r in results:
29
  im_array = r.plot()
30
  im_array = im_array.astype(np.uint8)
 
31
 
32
  if len(r.obb.cls) == 0: # If no objects are detected
33
  return None, "No objects detected."
 
2
  import gradio as gr
3
  from ultralytics import YOLO
4
  import numpy as np
5
+ import cv2
6
 
7
  model_options = ["yolo-8n-shiprs.pt", "yolo-8s-shiprs.pt", "yolo-8m-shiprs.pt"]
8
  model_names = ["Nano", "Small", "Medium"]
 
19
  if conf is None:
20
  conf = 0.6
21
 
22
+ input_image = cv2.cvtColor(input_image, cv2.COLOR_RGB2BGR)
23
+
24
  model_index = model_names.index(model_name)
25
  model = models[model_index]
26
 
 
31
  for r in results:
32
  im_array = r.plot()
33
  im_array = im_array.astype(np.uint8)
34
+ im_array = cv2.cvtColor(im_array, cv2.COLOR_BGR2RGB)
35
 
36
  if len(r.obb.cls) == 0: # If no objects are detected
37
  return None, "No objects detected."