valentynliubchenko commited on
Commit
354684a
1 Parent(s): 74c67ab
Files changed (2) hide show
  1. app.py +4 -1
  2. input_image.jpg +0 -0
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import os
 
2
  import gradio as gr
3
  from ultralytics import YOLO
4
  import numpy as np
@@ -29,7 +30,8 @@ def process_image(input_image, model_name, conf):
29
  print('model_index: ')
30
  print(model_index)
31
  model = models[model_index]
32
-
 
33
  results = model.predict(input_image, conf=conf)
34
  class_counts = {}
35
  class_counts_str = "Class Counts:\n"
@@ -37,6 +39,7 @@ def process_image(input_image, model_name, conf):
37
  for r in results:
38
  im_array = r.plot()
39
  im_array = im_array.astype(np.uint8)
 
40
 
41
  if len(r.boxes) == 0: # If no objects are detected
42
  return None, "No objects detected."
 
1
  import os
2
+ import cv2
3
  import gradio as gr
4
  from ultralytics import YOLO
5
  import numpy as np
 
30
  print('model_index: ')
31
  print(model_index)
32
  model = models[model_index]
33
+ input_image = cv2.cvtColor(input_image, cv2.COLOR_RGB2BGR)
34
+ # cv2.imwrite('./input_image.jpg', input_image)
35
  results = model.predict(input_image, conf=conf)
36
  class_counts = {}
37
  class_counts_str = "Class Counts:\n"
 
39
  for r in results:
40
  im_array = r.plot()
41
  im_array = im_array.astype(np.uint8)
42
+ im_array = cv2.cvtColor(im_array, cv2.COLOR_BGR2RGB)
43
 
44
  if len(r.boxes) == 0: # If no objects are detected
45
  return None, "No objects detected."
input_image.jpg ADDED