Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,17 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import mlflow
|
| 3 |
-
import dagshub
|
| 4 |
-
from ultralytics import YOLO
|
| 5 |
-
from PIL import Image
|
| 6 |
-
import cv2
|
| 7 |
-
import numpy as np
|
| 8 |
import os
|
| 9 |
import time
|
| 10 |
import tempfile
|
| 11 |
import shutil
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
# ==============================
|
| 14 |
-
# MLflow
|
| 15 |
# ==============================
|
| 16 |
-
# Secrets من HF Spaces
|
| 17 |
tracking_uri = os.getenv("MLFLOW_TRACKING_URI")
|
| 18 |
username = os.getenv("MLFLOW_TRACKING_USERNAME")
|
| 19 |
password = os.getenv("MLFLOW_TRACKING_PASSWORD")
|
|
@@ -25,18 +23,14 @@ os.environ["MLFLOW_TRACKING_URI"] = tracking_uri
|
|
| 25 |
os.environ["MLFLOW_TRACKING_USERNAME"] = username
|
| 26 |
os.environ["MLFLOW_TRACKING_PASSWORD"] = password
|
| 27 |
|
| 28 |
-
# تفعيل DagsHub
|
| 29 |
-
dagshub.init(repo_owner="Mosensei7", repo_name="AutonomousVehiclesDetectionDEPI", mlflow=True)
|
| 30 |
-
|
| 31 |
# إنشاء experiment
|
| 32 |
mlflow.set_experiment("YOLOv12s_Inference_Logs")
|
| 33 |
-
|
| 34 |
-
print("MLflow connected successfully to DagsHub!")
|
| 35 |
|
| 36 |
# ==============================
|
| 37 |
# Load Model
|
| 38 |
# ==============================
|
| 39 |
-
model = YOLO("
|
| 40 |
|
| 41 |
# ==============================
|
| 42 |
# Inference with Full MLflow Tracking
|
|
@@ -128,7 +122,7 @@ h1 { text-align: center; color: #00ffff; text-shadow: 0 0 20px #00ffff; font-siz
|
|
| 128 |
button { background: linear-gradient(45deg, #ff00ff, #00ffff); border: none; border-radius: 20px; height: 60px; font-size: 1.3em; box-shadow: 0 0 25px #00ffff; }
|
| 129 |
"""
|
| 130 |
|
| 131 |
-
with gr.Blocks(css=css, theme=gr.themes.
|
| 132 |
gr.Markdown("""
|
| 133 |
# 🚀 YOLOv12s - كشف المركبات في الشوارع المصرية 🇪🇬
|
| 134 |
**كل عملية كشف بتترفع تلقائيًا على DagsHub MLflow مع الـ input والـ output والإحصائيات**
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import mlflow
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import os
|
| 4 |
import time
|
| 5 |
import tempfile
|
| 6 |
import shutil
|
| 7 |
+
from ultralytics import YOLO
|
| 8 |
+
from PIL import Image
|
| 9 |
+
import cv2
|
| 10 |
+
import numpy as np
|
| 11 |
|
| 12 |
# ==============================
|
| 13 |
+
# MLflow Configuration using Secrets ONLY
|
| 14 |
# ==============================
|
|
|
|
| 15 |
tracking_uri = os.getenv("MLFLOW_TRACKING_URI")
|
| 16 |
username = os.getenv("MLFLOW_TRACKING_USERNAME")
|
| 17 |
password = os.getenv("MLFLOW_TRACKING_PASSWORD")
|
|
|
|
| 23 |
os.environ["MLFLOW_TRACKING_USERNAME"] = username
|
| 24 |
os.environ["MLFLOW_TRACKING_PASSWORD"] = password
|
| 25 |
|
|
|
|
|
|
|
|
|
|
| 26 |
# إنشاء experiment
|
| 27 |
mlflow.set_experiment("YOLOv12s_Inference_Logs")
|
| 28 |
+
print("✅ MLflow configured successfully using secrets!")
|
|
|
|
| 29 |
|
| 30 |
# ==============================
|
| 31 |
# Load Model
|
| 32 |
# ==============================
|
| 33 |
+
model = YOLO("Mosensei7/yolov12s-egyptian-autonomous-vehicles/best.pt") # اسم الـ repo بتاعك
|
| 34 |
|
| 35 |
# ==============================
|
| 36 |
# Inference with Full MLflow Tracking
|
|
|
|
| 122 |
button { background: linear-gradient(45deg, #ff00ff, #00ffff); border: none; border-radius: 20px; height: 60px; font-size: 1.3em; box-shadow: 0 0 25px #00ffff; }
|
| 123 |
"""
|
| 124 |
|
| 125 |
+
with gr.Blocks(css=css, theme=gr.themes.Monochrome()) as demo: # ✅ FIXED THEME HERE
|
| 126 |
gr.Markdown("""
|
| 127 |
# 🚀 YOLOv12s - كشف المركبات في الشوارع المصرية 🇪🇬
|
| 128 |
**كل عملية كشف بتترفع تلقائيًا على DagsHub MLflow مع الـ input والـ output والإحصائيات**
|