bla commited on
Commit
1ca95e4
·
verified ·
1 Parent(s): 005ff51

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -208,16 +208,24 @@ class YOLOWorldDetector:
208
  # Run inference based on model type
209
  if self.model_type == "yoloworld":
210
  try:
 
 
 
 
 
 
 
211
  # YOLOWorld supports text prompts
212
  results = self.model.predict(
213
  source=image,
214
- classes=text_prompt.split(','),
215
  conf=confidence_threshold,
216
  verbose=False
217
  )
218
  except Exception as e:
219
  print(f"Error during YOLOWorld inference: {e}")
220
- # If YOLOWorld inference fails, try to use it as standard YOLO
 
221
  results = self.model.predict(
222
  source=image,
223
  conf=confidence_threshold,
@@ -449,4 +457,4 @@ with gr.Blocks(title="YOLO Vision Suite", css=custom_css) as demo:
449
  )
450
 
451
  if __name__ == "__main__":
452
- demo.launch()
 
208
  # Run inference based on model type
209
  if self.model_type == "yoloworld":
210
  try:
211
+ # Parse text prompt properly for YOLOWorld
212
+ if text_prompt and text_prompt.strip():
213
+ # Split by comma and strip whitespace
214
+ classes = [cls.strip() for cls in text_prompt.split(',') if cls.strip()]
215
+ else:
216
+ classes = None
217
+
218
  # YOLOWorld supports text prompts
219
  results = self.model.predict(
220
  source=image,
221
+ classes=classes, # Pass as a list of strings or None
222
  conf=confidence_threshold,
223
  verbose=False
224
  )
225
  except Exception as e:
226
  print(f"Error during YOLOWorld inference: {e}")
227
+ print("Falling back to standard YOLO inference...")
228
+ # If YOLOWorld inference fails, use standard YOLO
229
  results = self.model.predict(
230
  source=image,
231
  conf=confidence_threshold,
 
457
  )
458
 
459
  if __name__ == "__main__":
460
+ demo.launch(share=True) # Set share=True to create a public link