Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
# -*- coding: utf-8 -*-
|
| 3 |
"""
|
| 4 |
Sapphire OCR Engine - Ultra Safe Speed Route
|
|
|
|
| 5 |
"""
|
| 6 |
|
| 7 |
import os
|
|
@@ -12,7 +13,16 @@ import logging
|
|
| 12 |
import threading
|
| 13 |
from PIL import Image
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
import torch
|
| 17 |
import numpy as np
|
| 18 |
import gradio as gr
|
|
@@ -29,7 +39,9 @@ UPLOAD_FOLDER = "upload_tmp"
|
|
| 29 |
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
|
| 30 |
|
| 31 |
processing_lock = threading.Lock()
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
|
| 34 |
ocr_stats = {
|
| 35 |
"status": "🟢 المحرك مستقر تماماً وبانتظار البيانات...",
|
|
@@ -39,85 +51,131 @@ ocr_stats = {
|
|
| 39 |
"micro_logs": "🚀 السيرفر جاهز لاستقبال نبضات الرام والخزنة بالتتابع السريع..."
|
| 40 |
}
|
| 41 |
|
| 42 |
-
#
|
|
|
|
|
|
|
| 43 |
_ocr_reader = None
|
|
|
|
| 44 |
def get_ocr_reader():
|
| 45 |
global _ocr_reader
|
| 46 |
if _ocr_reader is None:
|
| 47 |
import easyocr
|
| 48 |
-
logger.info("📥 [Lazy Load] جاري شحن محرك EasyOCR
|
| 49 |
_ocr_reader = easyocr.Reader(['ar', 'en'], gpu=torch.cuda.is_available())
|
| 50 |
return _ocr_reader
|
| 51 |
|
|
|
|
|
|
|
|
|
|
| 52 |
def advanced_image_filter_from_matrix(img_np: np.ndarray) -> np.ndarray:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
try:
|
| 54 |
blurred = cv2.GaussianBlur(img_np, (3, 3), 0)
|
| 55 |
-
return cv2.adaptiveThreshold(
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
#
|
|
|
|
|
|
|
| 59 |
def core_ocr_and_forward_to_golden(filename: str, file_path: str, is_vip: bool = False):
|
| 60 |
global ocr_stats
|
| 61 |
-
prefix = "👑 [VIP
|
| 62 |
logger.info(f"{prefix} بدء معالجة المستند: {filename}")
|
| 63 |
ocr_stats["status"] = f"🔎 جاري معالجة {filename}..."
|
| 64 |
-
|
| 65 |
final_text = ""
|
| 66 |
try:
|
| 67 |
reader = get_ocr_reader()
|
|
|
|
|
|
|
| 68 |
if filename.lower().endswith('.pdf'):
|
| 69 |
doc = fitz.open(file_path)
|
| 70 |
native_text = ""
|
|
|
|
| 71 |
for page in doc:
|
| 72 |
t = page.get_text()
|
| 73 |
-
if t and len(t.strip()) > 15:
|
| 74 |
-
|
|
|
|
| 75 |
if native_text.strip():
|
| 76 |
final_text = native_text
|
| 77 |
else:
|
| 78 |
-
# معالجة صفحة تلو الأخرى مع تنظيف فوري للذاكرة لمنع تعليق اللوج
|
| 79 |
for page_num in range(len(doc)):
|
| 80 |
page = doc[page_num]
|
| 81 |
-
pix = page.get_pixmap(dpi=100)
|
| 82 |
img_np = np.frombuffer(pix.samples, dtype=np.uint8).reshape(pix.h, pix.w, pix.n)
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
final_text += "\n".join(ocr_results) + "\n"
|
| 87 |
-
|
| 88 |
-
del pix, img_np, open_cv_image,
|
| 89 |
gc.collect()
|
|
|
|
| 90 |
doc.close()
|
|
|
|
|
|
|
| 91 |
else:
|
| 92 |
img_pil = Image.open(file_path)
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
ocr_results = reader.readtext(
|
| 96 |
final_text += "\n".join(ocr_results)
|
| 97 |
|
| 98 |
-
#
|
| 99 |
if final_text.strip():
|
| 100 |
try:
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
except Exception as forward_err:
|
| 104 |
-
logger.error(f"⚠️ المعالج الذهبي
|
| 105 |
|
| 106 |
-
# تحديث ل
|
| 107 |
ocr_stats["total_extracted_words"] += len(final_text.split())
|
| 108 |
ocr_stats["processed_files_count"] += 1
|
| 109 |
-
ocr_stats["last_processed_file"] = f"{prefix} {filename}
|
| 110 |
-
ocr_stats["micro_logs"] = f"
|
| 111 |
-
|
| 112 |
return final_text
|
|
|
|
| 113 |
except Exception as e:
|
| 114 |
logger.error(f"❌ خطأ في معالجة {filename}: {e}")
|
| 115 |
return None
|
|
|
|
| 116 |
finally:
|
| 117 |
-
ocr_stats["status"] = "🟢 المحرك مستقر
|
| 118 |
gc.collect()
|
| 119 |
|
| 120 |
-
#
|
|
|
|
|
|
|
| 121 |
def cloud_folder_polling_worker():
|
| 122 |
REPO_ID = "Asem75/aiocr_asistant"
|
| 123 |
while True:
|
|
@@ -126,85 +184,93 @@ def cloud_folder_polling_worker():
|
|
| 126 |
try:
|
| 127 |
api = HfApi(token=token)
|
| 128 |
all_files = api.list_repo_files(repo_id=REPO_ID, repo_type="dataset")
|
| 129 |
-
valid_files = [f for f in all_files if f.lower().startswith("raw_files/")
|
| 130 |
-
|
| 131 |
if valid_files:
|
| 132 |
target_file = valid_files[0]
|
| 133 |
with processing_lock:
|
| 134 |
filename = os.path.basename(target_file)
|
| 135 |
local_path = os.path.join(UPLOAD_FOLDER, f"radar_{filename}")
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
|
|
|
| 146 |
except Exception as e:
|
| 147 |
-
logger.error(f"⚠️ خطأ
|
|
|
|
| 148 |
time.sleep(6)
|
| 149 |
|
| 150 |
-
|
| 151 |
-
polling_thread.start()
|
| 152 |
|
| 153 |
-
#
|
|
|
|
|
|
|
| 154 |
fastapi_app = FastAPI()
|
| 155 |
|
| 156 |
@fastapi_app.post("/api/predict")
|
| 157 |
async def handle_vip_direct_network_route(request: Request):
|
| 158 |
-
"""
|
| 159 |
-
بوابة الرام الشريانية المصممة خصيصاً لاستقبال طلبات الـ VIP من واجهة الرفع بدون أي وسيط
|
| 160 |
-
"""
|
| 161 |
try:
|
| 162 |
payload = await request.json()
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
if "base64," in raw_b64_string:
|
| 173 |
-
raw_b64_string = raw_b64_string.split("base64,")[1]
|
| 174 |
-
|
| 175 |
import base64
|
| 176 |
-
local_path = os.path.join(UPLOAD_FOLDER, f"
|
|
|
|
| 177 |
with open(local_path, "wb") as fh:
|
| 178 |
-
fh.write(base64.b64decode(
|
| 179 |
-
|
| 180 |
-
# معالجة فورية وحجز المعالج
|
| 181 |
with processing_lock:
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
return JSONResponse(content={"data": [
|
| 188 |
-
except Exception as api_err:
|
| 189 |
-
logger.error(f"❌ فشل استقبال حزمة الـ VIP في بوابة الرام: {api_err}")
|
| 190 |
-
return JSONResponse(content={"error": str(api_err)}, status_code=500)
|
| 191 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
def get_dashboard_data():
|
| 193 |
-
return (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
with gr.Blocks(title="Sapphire OCR - Route Management") as demo:
|
| 196 |
-
gr.HTML("<
|
| 197 |
-
status_box = gr.Textbox(label="📡
|
|
|
|
| 198 |
with gr.Row():
|
| 199 |
-
count_box = gr.Textbox(label="
|
| 200 |
-
words_box = gr.Textbox(label="
|
| 201 |
-
last_file_box = gr.Textbox(label="
|
| 202 |
-
|
| 203 |
-
|
|
|
|
| 204 |
refresh_btn.click(fn=get_dashboard_data, outputs=[status_box, count_box, words_box, last_file_box, logs_box])
|
| 205 |
|
| 206 |
app = gr.mount_gradio_app(fastapi_app, demo, path="/")
|
| 207 |
|
| 208 |
if __name__ == "__main__":
|
| 209 |
import uvicorn
|
| 210 |
-
uvicorn.run(app, host="0.0.0.0", port=7860
|
|
|
|
| 2 |
# -*- coding: utf-8 -*-
|
| 3 |
"""
|
| 4 |
Sapphire OCR Engine - Ultra Safe Speed Route
|
| 5 |
+
(مُعدَّل للربط المباشر مع المعالج الذهبي عبر RAM VIP)
|
| 6 |
"""
|
| 7 |
|
| 8 |
import os
|
|
|
|
| 13 |
import threading
|
| 14 |
from PIL import Image
|
| 15 |
|
| 16 |
+
# ============================================================
|
| 17 |
+
# 🔧 إصلاح مشكلة cv2 — تحميل آمن مع بديل تلقائي
|
| 18 |
+
# ============================================================
|
| 19 |
+
try:
|
| 20 |
+
import cv2
|
| 21 |
+
CV2_AVAILABLE = True
|
| 22 |
+
except ImportError:
|
| 23 |
+
CV2_AVAILABLE = False
|
| 24 |
+
print("⚠️ مكتبة cv2 غير مثبتة — سيتم استخدام بديل مبسط تلقائيًا.")
|
| 25 |
+
|
| 26 |
import torch
|
| 27 |
import numpy as np
|
| 28 |
import gradio as gr
|
|
|
|
| 39 |
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
|
| 40 |
|
| 41 |
processing_lock = threading.Lock()
|
| 42 |
+
|
| 43 |
+
# --- رابط المعالج الذهبي ---
|
| 44 |
+
GOLDEN_ENGINE_API_URL = "https://asem75-aiarabicengen.hf.space/api/submit_ocr_data"
|
| 45 |
|
| 46 |
ocr_stats = {
|
| 47 |
"status": "🟢 المحرك مستقر تماماً وبانتظار البيانات...",
|
|
|
|
| 51 |
"micro_logs": "🚀 السيرفر جاهز لاستقبال نبضات الرام والخزنة بالتتابع السريع..."
|
| 52 |
}
|
| 53 |
|
| 54 |
+
# ============================================================
|
| 55 |
+
# 🧠 Lazy Loading لمحرك EasyOCR
|
| 56 |
+
# ============================================================
|
| 57 |
_ocr_reader = None
|
| 58 |
+
|
| 59 |
def get_ocr_reader():
|
| 60 |
global _ocr_reader
|
| 61 |
if _ocr_reader is None:
|
| 62 |
import easyocr
|
| 63 |
+
logger.info("📥 [Lazy Load] جاري شحن محرك EasyOCR...")
|
| 64 |
_ocr_reader = easyocr.Reader(['ar', 'en'], gpu=torch.cuda.is_available())
|
| 65 |
return _ocr_reader
|
| 66 |
|
| 67 |
+
# ============================================================
|
| 68 |
+
# 🧹 فلتر الصور — يعمل سواء كانت cv2 موجودة أو لا
|
| 69 |
+
# ============================================================
|
| 70 |
def advanced_image_filter_from_matrix(img_np: np.ndarray) -> np.ndarray:
|
| 71 |
+
if not CV2_AVAILABLE:
|
| 72 |
+
# بديل بسيط بدون OpenCV
|
| 73 |
+
return img_np
|
| 74 |
+
|
| 75 |
try:
|
| 76 |
blurred = cv2.GaussianBlur(img_np, (3, 3), 0)
|
| 77 |
+
return cv2.adaptiveThreshold(
|
| 78 |
+
blurred, 255,
|
| 79 |
+
cv2.ADAPTIVE_THRESH_GAUSSIAN_C,
|
| 80 |
+
cv2.THRESH_BINARY,
|
| 81 |
+
11, 2
|
| 82 |
+
)
|
| 83 |
+
except Exception:
|
| 84 |
+
return img_np
|
| 85 |
|
| 86 |
+
# ============================================================
|
| 87 |
+
# 🧠 الدالة المركزية للـ OCR
|
| 88 |
+
# ============================================================
|
| 89 |
def core_ocr_and_forward_to_golden(filename: str, file_path: str, is_vip: bool = False):
|
| 90 |
global ocr_stats
|
| 91 |
+
prefix = "👑 [VIP]" if is_vip else "🐢 [FREE]"
|
| 92 |
logger.info(f"{prefix} بدء معالجة المستند: {filename}")
|
| 93 |
ocr_stats["status"] = f"🔎 جاري معالجة {filename}..."
|
| 94 |
+
|
| 95 |
final_text = ""
|
| 96 |
try:
|
| 97 |
reader = get_ocr_reader()
|
| 98 |
+
|
| 99 |
+
# ---------------- PDF ----------------
|
| 100 |
if filename.lower().endswith('.pdf'):
|
| 101 |
doc = fitz.open(file_path)
|
| 102 |
native_text = ""
|
| 103 |
+
|
| 104 |
for page in doc:
|
| 105 |
t = page.get_text()
|
| 106 |
+
if t and len(t.strip()) > 15:
|
| 107 |
+
native_text += t + "\n"
|
| 108 |
+
|
| 109 |
if native_text.strip():
|
| 110 |
final_text = native_text
|
| 111 |
else:
|
|
|
|
| 112 |
for page_num in range(len(doc)):
|
| 113 |
page = doc[page_num]
|
| 114 |
+
pix = page.get_pixmap(dpi=100)
|
| 115 |
img_np = np.frombuffer(pix.samples, dtype=np.uint8).reshape(pix.h, pix.w, pix.n)
|
| 116 |
+
|
| 117 |
+
if CV2_AVAILABLE:
|
| 118 |
+
open_cv_image = cv2.cvtColor(img_np, cv2.COLOR_RGB2GRAY)
|
| 119 |
+
else:
|
| 120 |
+
open_cv_image = img_np.mean(axis=2).astype(np.uint8)
|
| 121 |
+
|
| 122 |
+
cleaned = advanced_image_filter_from_matrix(open_cv_image)
|
| 123 |
+
ocr_results = reader.readtext(cleaned, detail=0)
|
| 124 |
final_text += "\n".join(ocr_results) + "\n"
|
| 125 |
+
|
| 126 |
+
del pix, img_np, open_cv_image, cleaned
|
| 127 |
gc.collect()
|
| 128 |
+
|
| 129 |
doc.close()
|
| 130 |
+
|
| 131 |
+
# ---------------- IMAGE ----------------
|
| 132 |
else:
|
| 133 |
img_pil = Image.open(file_path)
|
| 134 |
+
gray = np.array(img_pil.convert('L'))
|
| 135 |
+
cleaned = advanced_image_filter_from_matrix(gray)
|
| 136 |
+
ocr_results = reader.readtext(cleaned, detail=0)
|
| 137 |
final_text += "\n".join(ocr_results)
|
| 138 |
|
| 139 |
+
# ---------------- إرسال للمعالج الذهبي ----------------
|
| 140 |
if final_text.strip():
|
| 141 |
try:
|
| 142 |
+
rank = "vip" if is_vip else "free"
|
| 143 |
+
username = "VIP_User" if is_vip else "Free_OCR"
|
| 144 |
+
|
| 145 |
+
logger.info(f"🚀 إرسال النص المستخرج لـ {filename} إلى المحرك الذهبي...")
|
| 146 |
+
response = requests.post(
|
| 147 |
+
GOLDEN_ENGINE_API_URL,
|
| 148 |
+
json={"data": [final_text, username, rank]},
|
| 149 |
+
timeout=10
|
| 150 |
+
)
|
| 151 |
+
|
| 152 |
+
if response.status_code == 200:
|
| 153 |
+
logger.info("✅ تم الإرسال بنجاح")
|
| 154 |
+
else:
|
| 155 |
+
logger.warning(f"⚠️ استجابة غير متوقعة: {response.status_code}")
|
| 156 |
+
|
| 157 |
except Exception as forward_err:
|
| 158 |
+
logger.error(f"⚠️ فشل الإرسال للمعالج الذهبي: {forward_err}")
|
| 159 |
|
| 160 |
+
# ---------------- تحديث الإحصائيات ----------------
|
| 161 |
ocr_stats["total_extracted_words"] += len(final_text.split())
|
| 162 |
ocr_stats["processed_files_count"] += 1
|
| 163 |
+
ocr_stats["last_processed_file"] = f"{prefix} {filename}"
|
| 164 |
+
ocr_stats["micro_logs"] = f"تم الانتهاء من {filename}"
|
| 165 |
+
|
| 166 |
return final_text
|
| 167 |
+
|
| 168 |
except Exception as e:
|
| 169 |
logger.error(f"❌ خطأ في معالجة {filename}: {e}")
|
| 170 |
return None
|
| 171 |
+
|
| 172 |
finally:
|
| 173 |
+
ocr_stats["status"] = "🟢 المحرك مستقر"
|
| 174 |
gc.collect()
|
| 175 |
|
| 176 |
+
# ============================================================
|
| 177 |
+
# 🛰️ رادار المجانيين
|
| 178 |
+
# ============================================================
|
| 179 |
def cloud_folder_polling_worker():
|
| 180 |
REPO_ID = "Asem75/aiocr_asistant"
|
| 181 |
while True:
|
|
|
|
| 184 |
try:
|
| 185 |
api = HfApi(token=token)
|
| 186 |
all_files = api.list_repo_files(repo_id=REPO_ID, repo_type="dataset")
|
| 187 |
+
valid_files = [f for f in all_files if f.lower().startswith("raw_files/")]
|
| 188 |
+
|
| 189 |
if valid_files:
|
| 190 |
target_file = valid_files[0]
|
| 191 |
with processing_lock:
|
| 192 |
filename = os.path.basename(target_file)
|
| 193 |
local_path = os.path.join(UPLOAD_FOLDER, f"radar_{filename}")
|
| 194 |
+
downloaded = hf_hub_download(repo_id=REPO_ID, filename=target_file, repo_type="dataset", token=token)
|
| 195 |
+
|
| 196 |
+
shutil.copy2(downloaded, local_path)
|
| 197 |
+
result = core_ocr_and_forward_to_golden(filename, local_path, is_vip=False)
|
| 198 |
+
|
| 199 |
+
if result is not None:
|
| 200 |
+
api.delete_file(path_in_repo=target_file, repo_id=REPO_ID, repo_type="dataset", token=token)
|
| 201 |
+
|
| 202 |
+
if os.path.exists(local_path):
|
| 203 |
+
os.remove(local_path)
|
| 204 |
+
|
| 205 |
except Exception as e:
|
| 206 |
+
logger.error(f"⚠️ خطأ في الرادار: {e}")
|
| 207 |
+
|
| 208 |
time.sleep(6)
|
| 209 |
|
| 210 |
+
threading.Thread(target=cloud_folder_polling_worker, daemon=True).start()
|
|
|
|
| 211 |
|
| 212 |
+
# ============================================================
|
| 213 |
+
# 🛡️ بوابة VIP عبر الشبكة
|
| 214 |
+
# ============================================================
|
| 215 |
fastapi_app = FastAPI()
|
| 216 |
|
| 217 |
@fastapi_app.post("/api/predict")
|
| 218 |
async def handle_vip_direct_network_route(request: Request):
|
|
|
|
|
|
|
|
|
|
| 219 |
try:
|
| 220 |
payload = await request.json()
|
| 221 |
+
file_info = payload.get("data", [])[0]
|
| 222 |
+
|
| 223 |
+
filename = file_info.get("name", "vip_file")
|
| 224 |
+
raw_b64 = file_info.get("data", "")
|
| 225 |
+
|
| 226 |
+
if "base64," in raw_b64:
|
| 227 |
+
raw_b64 = raw_b64.split("base64,")[1]
|
| 228 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
import base64
|
| 230 |
+
local_path = os.path.join(UPLOAD_FOLDER, f"vip_{filename}")
|
| 231 |
+
|
| 232 |
with open(local_path, "wb") as fh:
|
| 233 |
+
fh.write(base64.b64decode(raw_b64))
|
| 234 |
+
|
|
|
|
| 235 |
with processing_lock:
|
| 236 |
+
extracted = core_ocr_and_forward_to_golden(filename, local_path, is_vip=True)
|
| 237 |
+
|
| 238 |
+
if os.path.exists(local_path):
|
| 239 |
+
os.remove(local_path)
|
| 240 |
+
|
| 241 |
+
return JSONResponse(content={"data": [extracted or "❌ فشل استخراج النص"]})
|
|
|
|
|
|
|
|
|
|
| 242 |
|
| 243 |
+
except Exception as e:
|
| 244 |
+
logger.error(f"❌ خطأ VIP: {e}")
|
| 245 |
+
return JSONResponse(content={"error": str(e)}, status_code=500)
|
| 246 |
+
|
| 247 |
+
# ============================================================
|
| 248 |
+
# 🖥️ لوحة التحكم
|
| 249 |
+
# ============================================================
|
| 250 |
def get_dashboard_data():
|
| 251 |
+
return (
|
| 252 |
+
ocr_stats["status"],
|
| 253 |
+
str(ocr_stats["processed_files_count"]),
|
| 254 |
+
str(ocr_stats["total_extracted_words"]),
|
| 255 |
+
ocr_stats["last_processed_file"],
|
| 256 |
+
ocr_stats["micro_logs"]
|
| 257 |
+
)
|
| 258 |
|
| 259 |
with gr.Blocks(title="Sapphire OCR - Route Management") as demo:
|
| 260 |
+
gr.HTML("<h1 style='text-align:center;'>🔮 Sapphire OCR Engine V2</h1>")
|
| 261 |
+
status_box = gr.Textbox(label="📡 الحالة", value=ocr_stats["status"], interactive=False)
|
| 262 |
+
|
| 263 |
with gr.Row():
|
| 264 |
+
count_box = gr.Textbox(label="📁 عدد الملفات", value="0", interactive=False)
|
| 265 |
+
words_box = gr.Textbox(label="🔤 عدد الكلمات", value="0", interactive=False)
|
| 266 |
+
last_file_box = gr.Textbox(label="📄 آخر ملف", value="لا يوجد", interactive=False)
|
| 267 |
+
|
| 268 |
+
logs_box = gr.Textbox(label="📝 السجل", value=ocr_stats["micro_logs"], lines=3, interactive=False)
|
| 269 |
+
refresh_btn = gr.Button("🔄 تحديث")
|
| 270 |
refresh_btn.click(fn=get_dashboard_data, outputs=[status_box, count_box, words_box, last_file_box, logs_box])
|
| 271 |
|
| 272 |
app = gr.mount_gradio_app(fastapi_app, demo, path="/")
|
| 273 |
|
| 274 |
if __name__ == "__main__":
|
| 275 |
import uvicorn
|
| 276 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|