Spaces:
Running
on
Zero
Running
on
Zero
atalaydenknalbant
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,21 @@ import spaces
|
|
5 |
|
6 |
@spaces.GPU
|
7 |
def yolo_inference(images, model_id, conf_threshold, iou_threshold, max_detection):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
model = YOLO(model_id)
|
9 |
results = model.predict(
|
10 |
source=images,
|
|
|
5 |
|
6 |
@spaces.GPU
|
7 |
def yolo_inference(images, model_id, conf_threshold, iou_threshold, max_detection):
|
8 |
+
if images is None:
|
9 |
+
# Create a blank image
|
10 |
+
width, height = 640, 480
|
11 |
+
blank_image = Image.new("RGB", (width, height), color="white")
|
12 |
+
draw = ImageDraw.Draw(blank_image)
|
13 |
+
message = "No image provided"
|
14 |
+
font = ImageFont.load_default(size=40)
|
15 |
+
bbox = draw.textbbox((0, 0), message, font=font)
|
16 |
+
text_width = bbox[2] - bbox[0]
|
17 |
+
text_height = bbox[3] - bbox[1]
|
18 |
+
text_x = (width - text_width) / 2
|
19 |
+
text_y = (height - text_height) / 2
|
20 |
+
draw.text((text_x, text_y), message, fill="black", font=font)
|
21 |
+
return blank_image
|
22 |
+
|
23 |
model = YOLO(model_id)
|
24 |
results = model.predict(
|
25 |
source=images,
|