Spaces:
Sleeping
Sleeping
jovian
commited on
Commit
·
b1600c9
1
Parent(s):
62ff115
company label model
Browse files
app.py
CHANGED
|
@@ -6,7 +6,6 @@ from sahi import AutoDetectionModel
|
|
| 6 |
from PIL import Image
|
| 7 |
import plotly.graph_objects as go
|
| 8 |
import torch
|
| 9 |
-
import spaces
|
| 10 |
|
| 11 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
| 12 |
|
|
@@ -15,7 +14,7 @@ class Detection:
|
|
| 15 |
|
| 16 |
def __init__(self):
|
| 17 |
# Set the model path and confidence threshold
|
| 18 |
-
yolov8_model_path = "./model/
|
| 19 |
|
| 20 |
# Initialize the AutoDetectionModel
|
| 21 |
self.model = AutoDetectionModel.from_pretrained(
|
|
@@ -113,7 +112,7 @@ class Detection:
|
|
| 113 |
name=category,
|
| 114 |
marker_color=self.get_color(category), # Use associated color
|
| 115 |
opacity=1,
|
| 116 |
-
nbinsx=
|
| 117 |
)
|
| 118 |
fig.add_trace(histogram_data)
|
| 119 |
|
|
@@ -209,7 +208,6 @@ def upload_image(image):
|
|
| 209 |
"""Process the uploaded image (if needed) and display it."""
|
| 210 |
return image
|
| 211 |
|
| 212 |
-
@spaces.GPU
|
| 213 |
def apply_detection(image):
|
| 214 |
"""Run object detection on the uploaded image and return the annotated image."""
|
| 215 |
# Convert image from PIL to NumPy array
|
|
|
|
| 6 |
from PIL import Image
|
| 7 |
import plotly.graph_objects as go
|
| 8 |
import torch
|
|
|
|
| 9 |
|
| 10 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
| 11 |
|
|
|
|
| 14 |
|
| 15 |
def __init__(self):
|
| 16 |
# Set the model path and confidence threshold
|
| 17 |
+
yolov8_model_path = "./model/company_model.pt" # Update to your model path
|
| 18 |
|
| 19 |
# Initialize the AutoDetectionModel
|
| 20 |
self.model = AutoDetectionModel.from_pretrained(
|
|
|
|
| 112 |
name=category,
|
| 113 |
marker_color=self.get_color(category), # Use associated color
|
| 114 |
opacity=1,
|
| 115 |
+
nbinsx=50 # Number of bins
|
| 116 |
)
|
| 117 |
fig.add_trace(histogram_data)
|
| 118 |
|
|
|
|
| 208 |
"""Process the uploaded image (if needed) and display it."""
|
| 209 |
return image
|
| 210 |
|
|
|
|
| 211 |
def apply_detection(image):
|
| 212 |
"""Run object detection on the uploaded image and return the annotated image."""
|
| 213 |
# Convert image from PIL to NumPy array
|