Spaces:
Runtime error
Runtime error
import gradio as gr | |
from gradio import components as gc | |
import cv2 | |
import requests | |
import os | |
from ultralyticsplus import YOLO, render_result | |
# Model Heading and Description | |
model_heading = "StockMarket: Trends Recognition for Trading Success" | |
description = "... (rest of the description) ..." | |
image_path = [['test/1.jpg', 'foduucom/stockmarket-future-prediction', 640, 0.25, 0.45], ...] | |
# Load YOLO model | |
model = YOLO("foduucom/stockmarket-future-prediction") | |
def yolov8_img_inference( | |
image: gc.Image = None, | |
model_path: str = "foduucom/stockmarket-future-prediction", | |
image_size: gc.Slider = 640, | |
conf_threshold: gc.Slider = 0.25, | |
iou_threshold: gc.Slider = 0.45 | |
): | |
model = YOLO(model_path) | |
model.overrides['conf'] = conf_threshold | |
model.overrides['iou'] = iou_threshold | |
model.overrides['agnostic_nms'] = False | |
model.overrides['max_det'] = 1000 | |
results = model.predict(image) | |
render = render_result(model=model, image=image, result=results[0]) | |
return render | |
inputs_image = [ | |
gc.Image(type="filepath", label="Input Image"), | |
gc.Dropdown(["foduucom/stockmarket-future-prediction"], default="foduucom/stockmarket-future-prediction", label="Model"), | |
gc.Slider(minimum=320, maximum=1280, default=640, step=32, label="Image Size"), | |
gc.Slider(minimum=0.0, maximum=1.0, default=0.25, step=0.05, label="Confidence Threshold"), | |
gc.Slider(minimum=0.0, maximum=1.0, default=0.45, step=0.05, label="IOU Threshold"), | |
] | |
outputs_image = gc.Image(type="filepath", label="Output Image") | |
interface_image = gr.Interface( | |
fn=yolov8_img_inference, | |
inputs=inputs_image, | |
outputs=outputs_image, | |
title=model_heading, | |
description=description, | |
examples=image_path, | |
cache_examples=False, | |
theme='huggingface' | |
) | |
interface_image.queue() | |
interface_image.launch(debug=True) | |