Martin Tomov commited on
Commit
58e191c
·
verified ·
1 Parent(s): 2065714

cv2.cvtColor experiment

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -151,11 +151,12 @@ def extract_and_paste_insect(original_image: np.ndarray, detection: DetectionRes
151
  background[y_offset:y_end, x_offset:x_end] = insect
152
 
153
  def create_yellow_background_with_insects(image: np.ndarray, detections: List[DetectionResult]) -> np.ndarray:
154
- yellow_background = np.full((image.shape[0], image.shape[1], 3), (0, 255, 255), dtype=np.uint8) # BGR for yellow in OpenCV
155
- yellow_background[:] = (0, 255, 255) # Ensuring it's yellow
156
  for detection in detections:
157
  if detection.mask is not None:
158
  extract_and_paste_insect(image, detection, yellow_background)
 
 
159
  return yellow_background
160
 
161
  def run_length_encoding(mask):
 
151
  background[y_offset:y_end, x_offset:x_end] = insect
152
 
153
  def create_yellow_background_with_insects(image: np.ndarray, detections: List[DetectionResult]) -> np.ndarray:
154
+ yellow_background = np.full((image.shape[0], image.shape[1], 3), (0, 255, 255), dtype=np.uint8) # BGR for yellow
 
155
  for detection in detections:
156
  if detection.mask is not None:
157
  extract_and_paste_insect(image, detection, yellow_background)
158
+ # Convert back to RGB to match Gradio's expected input format
159
+ yellow_background = cv2.cvtColor(yellow_background, cv2.COLOR_BGR2RGB)
160
  return yellow_background
161
 
162
  def run_length_encoding(mask):