nehulagrawal commited on
Commit
13fd314
1 Parent(s): bd7ded1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -10
app.py CHANGED
@@ -23,21 +23,29 @@ model = YOLO('foduucom/stockmarket-future-prediction')
23
 
24
  #############################################################Image Inference############################################################
25
  def yolov8_img_inference(
26
- image: gr.Input(type="filepath", label="Input Image"),
27
- model_path: str = 'foduucom/stockmarket-future-prediction', # Provide a default value
28
- image_size: gr.Input(type="number", minimum=320, maximum=1280, default=640, step=32, label="Image Size"),
29
- conf_threshold: gr.Input(type="number", minimum=0.0, maximum=1.0, default=0.25, step=0.05, label="Confidence Threshold"),
30
- iou_threshold: gr.Input(type="number", minimum=0.0, maximum=1.0, default=0.45, step=0.05, label="IOU Threshold"),
31
  ):
32
- # Ensure that model_path is not None before creating the YOLO model
33
- if model_path is None:
34
- model_path = 'foduucom/stockmarket-future-prediction'
35
-
 
 
 
 
 
 
 
36
  model = YOLO(model_path)
37
  model.overrides['conf'] = conf_threshold
38
- model.overrides['iou'] = iou_threshold
39
  model.overrides['agnostic_nms'] = False # NMS class-agnostic
40
  model.overrides['max_det'] = 1000
 
41
  results = model.predict(image)
42
  render = render_result(model=model, image=image, result=results[0])
43
 
 
23
 
24
  #############################################################Image Inference############################################################
25
  def yolov8_img_inference(
26
+ image: gr.inputs.Image = None,
27
+ model_path: gr.inputs.Dropdown = None,
28
+ image_size: gr.inputs.Slider = 640,
29
+ conf_threshold: gr.inputs.Slider = 0.25,
30
+ iou_threshold: gr.inputs.Slider = 0.45,
31
  ):
32
+ """
33
+ YOLOv8 inference function
34
+ Args:
35
+ image: Input image
36
+ model_path: Path to the model
37
+ image_size: Image size
38
+ conf_threshold: Confidence threshold
39
+ iou_threshold: IOU threshold
40
+ Returns:
41
+ Rendered image
42
+ """
43
  model = YOLO(model_path)
44
  model.overrides['conf'] = conf_threshold
45
+ model.overrides['iou']= iou_threshold
46
  model.overrides['agnostic_nms'] = False # NMS class-agnostic
47
  model.overrides['max_det'] = 1000
48
+ # image = read_image(image)
49
  results = model.predict(image)
50
  render = render_result(model=model, image=image, result=results[0])
51