Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,6 @@
|
|
| 1 |
#!/usr/bin/env python
|
| 2 |
# coding: utf-8
|
| 3 |
|
| 4 |
-
# In[32]:
|
| 5 |
-
|
| 6 |
|
| 7 |
from ultralytics import YOLO
|
| 8 |
from PIL import Image, ImageDraw, ImageFont
|
|
@@ -52,7 +50,9 @@ def predict(pilimg):
|
|
| 52 |
|
| 53 |
annotated_image = pilimg.convert("RGB")
|
| 54 |
draw = ImageDraw.Draw(annotated_image)
|
| 55 |
-
|
|
|
|
|
|
|
| 56 |
|
| 57 |
if classified_type == classes[0]:
|
| 58 |
draw.text((300, 10), classified_type, fill="red", font=font)
|
|
@@ -79,14 +79,3 @@ interface = gr.Interface(
|
|
| 79 |
interface.launch(share=True)
|
| 80 |
|
| 81 |
|
| 82 |
-
# In[ ]:
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
# In[ ]:
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
|
|
|
| 1 |
#!/usr/bin/env python
|
| 2 |
# coding: utf-8
|
| 3 |
|
|
|
|
|
|
|
| 4 |
|
| 5 |
from ultralytics import YOLO
|
| 6 |
from PIL import Image, ImageDraw, ImageFont
|
|
|
|
| 50 |
|
| 51 |
annotated_image = pilimg.convert("RGB")
|
| 52 |
draw = ImageDraw.Draw(annotated_image)
|
| 53 |
+
font_path = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"
|
| 54 |
+
font = ImageFont.truetype(font_path, 30)
|
| 55 |
+
#font = ImageFont.truetype("font/arialbd.ttf", 30) # Use arial.ttf for bold font
|
| 56 |
|
| 57 |
if classified_type == classes[0]:
|
| 58 |
draw.text((300, 10), classified_type, fill="red", font=font)
|
|
|
|
| 79 |
interface.launch(share=True)
|
| 80 |
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|