Spaces:
Sleeping
Sleeping
Delete ui.py
Browse files
ui.py
DELETED
|
@@ -1,34 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import requests
|
| 3 |
-
import base64
|
| 4 |
-
from io import BytesIO
|
| 5 |
-
from PIL import Image
|
| 6 |
-
|
| 7 |
-
st.set_page_config(page_title="مترجم لغة الإشارة", layout="centered")
|
| 8 |
-
|
| 9 |
-
st.title("📂 مترجم النص إلى لغة إشارة")
|
| 10 |
-
st.write("اكتب الكلمة باللغة العربية لتحويلها إلى صورة إشارة")
|
| 11 |
-
|
| 12 |
-
word = st.text_input("أدخل الكلمة:", placeholder="مثلاً: جمجمة")
|
| 13 |
-
|
| 14 |
-
if st.button("تحويل"):
|
| 15 |
-
if word:
|
| 16 |
-
# رابط الـ API بتاعك (تأكد إنه نفس الرابط اللي شغال)
|
| 17 |
-
api_url = "http://localhost:7860/text-to-sign" # لو على نفس السيرفر بنستخدم localhost
|
| 18 |
-
|
| 19 |
-
try:
|
| 20 |
-
response = requests.post(api_url, data={'text': word})
|
| 21 |
-
data = response.json()
|
| 22 |
-
|
| 23 |
-
if data['status'] == "success":
|
| 24 |
-
st.success(f"الكلمة: {data['word']}")
|
| 25 |
-
# فك تشفير الصورة وعرضها
|
| 26 |
-
img_bytes = base64.b64decode(data['image_base64'])
|
| 27 |
-
img = Image.open(BytesIO(img_bytes))
|
| 28 |
-
st.image(img, caption=f"إشارة كلمة {word}", use_column_width=True)
|
| 29 |
-
else:
|
| 30 |
-
st.error("الكلمة غير موجودة في القاموس")
|
| 31 |
-
except Exception as e:
|
| 32 |
-
st.error(f"حدث خطأ في الاتصال بالسيرفر: {e}")
|
| 33 |
-
else:
|
| 34 |
-
st.warning("يرجى إدخال كلمة أولاً")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|