Spaces:
Runtime error
Runtime error
nehulagrawal
commited on
Commit
•
bd7ded1
1
Parent(s):
6a59816
Update app.py
Browse files
app.py
CHANGED
@@ -23,34 +23,27 @@ model = YOLO('foduucom/stockmarket-future-prediction')
|
|
23 |
|
24 |
#############################################################Image Inference############################################################
|
25 |
def yolov8_img_inference(
|
26 |
-
image: gr.
|
27 |
-
model_path:
|
28 |
-
image_size: gr.
|
29 |
-
conf_threshold: gr.
|
30 |
-
iou_threshold: gr.
|
31 |
):
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
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 |
|
52 |
return render
|
53 |
|
|
|
54 |
|
55 |
inputs_image = [
|
56 |
gr.inputs.Image(type="filepath", label="Input Image"),
|
|
|
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 |
|
44 |
return render
|
45 |
|
46 |
+
|
47 |
|
48 |
inputs_image = [
|
49 |
gr.inputs.Image(type="filepath", label="Input Image"),
|