Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ import PIL.Image as Image
|
|
| 6 |
import PIL.Image as Image
|
| 7 |
from ultralytics import YOLO
|
| 8 |
from huggingface_hub import hf_hub_download, HfApi
|
| 9 |
-
|
| 10 |
global repo_id
|
| 11 |
|
| 12 |
def download_models(model_id):
|
|
@@ -19,6 +19,9 @@ def get_model_filenames(repo_id, file_extension = ".pt"):
|
|
| 19 |
model_filenames = [file for file in files if file.endswith(file_extension)]
|
| 20 |
return model_filenames
|
| 21 |
|
|
|
|
|
|
|
|
|
|
| 22 |
repo_id = "atalaydenknalbant/asl-yolo-models"
|
| 23 |
model_filenames = get_model_filenames(repo_id)
|
| 24 |
print("Model filenames:", model_filenames)
|
|
@@ -37,10 +40,8 @@ def yolo_inference(image, model_id, conf_threshold, iou_threshold, max_detection
|
|
| 37 |
model = YOLO(model_path)
|
| 38 |
results = model(source=image, imgsz=640, iou=iou_threshold, conf=conf_threshold, verbose=False, max_det=max_detection)[0]
|
| 39 |
|
| 40 |
-
# Get the detections and convert them to the supervision Detections format
|
| 41 |
detections = sv.Detections.from_ultralytics(results)
|
| 42 |
|
| 43 |
-
# Prepare the labels
|
| 44 |
labels = [
|
| 45 |
f"{category_dict[class_id]} {confidence:.2f}"
|
| 46 |
for class_id, confidence in zip(detections.class_id, detections.confidence)
|
|
|
|
| 6 |
import PIL.Image as Image
|
| 7 |
from ultralytics import YOLO
|
| 8 |
from huggingface_hub import hf_hub_download, HfApi
|
| 9 |
+
import random
|
| 10 |
global repo_id
|
| 11 |
|
| 12 |
def download_models(model_id):
|
|
|
|
| 19 |
model_filenames = [file for file in files if file.endswith(file_extension)]
|
| 20 |
return model_filenames
|
| 21 |
|
| 22 |
+
def random_color():
|
| 23 |
+
return tuple(random.randint(0, 255) for _ in range(3))
|
| 24 |
+
|
| 25 |
repo_id = "atalaydenknalbant/asl-yolo-models"
|
| 26 |
model_filenames = get_model_filenames(repo_id)
|
| 27 |
print("Model filenames:", model_filenames)
|
|
|
|
| 40 |
model = YOLO(model_path)
|
| 41 |
results = model(source=image, imgsz=640, iou=iou_threshold, conf=conf_threshold, verbose=False, max_det=max_detection)[0]
|
| 42 |
|
|
|
|
| 43 |
detections = sv.Detections.from_ultralytics(results)
|
| 44 |
|
|
|
|
| 45 |
labels = [
|
| 46 |
f"{category_dict[class_id]} {confidence:.2f}"
|
| 47 |
for class_id, confidence in zip(detections.class_id, detections.confidence)
|