Update app.py
Browse files
app.py
CHANGED
@@ -5,19 +5,23 @@ import plotly.express as px
|
|
5 |
import numpy as np
|
6 |
import random
|
7 |
from ultralytics import YOLO
|
8 |
-
from sahi.models.yolov8 import *
|
|
|
9 |
from sahi.predict import get_sliced_prediction
|
10 |
from sahi.utils.cv import visualize_object_predictions
|
11 |
import PIL
|
12 |
|
13 |
-
model_base = "https://huggingface.co/mayrajeo/marine-vessel-detection/resolve/main/"
|
|
|
14 |
|
15 |
def inference(
|
16 |
im:gr.inputs.Image=None,
|
17 |
model_path:gr.inputs.Dropdown='YOLOv8n',
|
18 |
conf_thr:gr.inputs.Slider=0.25
|
19 |
):
|
20 |
-
model = Yolov8DetectionModel(model_path=f'{model_base}/{model_path}/{model_path}.pt',
|
|
|
|
|
21 |
device='cpu',
|
22 |
confidence_threshold=conf_thr,
|
23 |
image_size=640)
|
|
|
5 |
import numpy as np
|
6 |
import random
|
7 |
from ultralytics import YOLO
|
8 |
+
#from sahi.models.yolov8 import *
|
9 |
+
from src.sahi_onnx import *
|
10 |
from sahi.predict import get_sliced_prediction
|
11 |
from sahi.utils.cv import visualize_object_predictions
|
12 |
import PIL
|
13 |
|
14 |
+
#model_base = "https://huggingface.co/mayrajeo/marine-vessel-detection/resolve/main/"
|
15 |
+
model_base = 'onnx_models'
|
16 |
|
17 |
def inference(
|
18 |
im:gr.inputs.Image=None,
|
19 |
model_path:gr.inputs.Dropdown='YOLOv8n',
|
20 |
conf_thr:gr.inputs.Slider=0.25
|
21 |
):
|
22 |
+
#model = Yolov8DetectionModel(model_path=f'{model_base}/{model_path}/{model_path}.pt',
|
23 |
+
model = Yolov8onnxDetectionModel(model_path=f'{model_base}/{model_path}/best.onnx',
|
24 |
+
config_path=f'{model_base}/{model_path}/args.yaml''
|
25 |
device='cpu',
|
26 |
confidence_threshold=conf_thr,
|
27 |
image_size=640)
|