Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,13 +60,24 @@
|
|
| 60 |
|
| 61 |
|
| 62 |
|
|
|
|
|
|
|
| 63 |
from ultralytics import YOLO
|
| 64 |
import pandas as pd
|
| 65 |
from PIL import Image, ImageDraw
|
| 66 |
import gradio as gr
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
# تحميل الموديل
|
| 69 |
-
model = YOLO(
|
| 70 |
|
| 71 |
# تحميل بيانات التغذية
|
| 72 |
food_df = pd.read_csv("food_cleaned.csv")
|
|
@@ -89,7 +100,7 @@ def detect(image):
|
|
| 89 |
boxes = result.boxes
|
| 90 |
names = model.names
|
| 91 |
|
| 92 |
-
img = Image.fromarray(result.plot()) # الصورة
|
| 93 |
draw = ImageDraw.Draw(img)
|
| 94 |
|
| 95 |
for box in boxes:
|
|
@@ -111,3 +122,4 @@ demo = gr.Interface(
|
|
| 111 |
)
|
| 112 |
|
| 113 |
demo.launch()
|
|
|
|
|
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
+
import os
|
| 64 |
+
import requests
|
| 65 |
from ultralytics import YOLO
|
| 66 |
import pandas as pd
|
| 67 |
from PIL import Image, ImageDraw
|
| 68 |
import gradio as gr
|
| 69 |
|
| 70 |
+
# تحميل الموديل من Hugging Face لو مش موجود
|
| 71 |
+
model_path = "best.pt"
|
| 72 |
+
model_url = "https://huggingface.co/AlaaElsayed/yolospace/resolve/main/best.pt"
|
| 73 |
+
|
| 74 |
+
if not os.path.exists(model_path):
|
| 75 |
+
r = requests.get(model_url)
|
| 76 |
+
with open(model_path, "wb") as f:
|
| 77 |
+
f.write(r.content)
|
| 78 |
+
|
| 79 |
# تحميل الموديل
|
| 80 |
+
model = YOLO(model_path)
|
| 81 |
|
| 82 |
# تحميل بيانات التغذية
|
| 83 |
food_df = pd.read_csv("food_cleaned.csv")
|
|
|
|
| 100 |
boxes = result.boxes
|
| 101 |
names = model.names
|
| 102 |
|
| 103 |
+
img = Image.fromarray(result.plot()) # الصورة مع البوكسات
|
| 104 |
draw = ImageDraw.Draw(img)
|
| 105 |
|
| 106 |
for box in boxes:
|
|
|
|
| 122 |
)
|
| 123 |
|
| 124 |
demo.launch()
|
| 125 |
+
|