Spaces:
Sleeping
Sleeping
Upload ui.py
Browse files
ui.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 = "https://ahmedda-arabic-sign-language-api.hf.space" # لو على نفس السيرفر بنستخدم 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("يرجى إدخال كلمة أولاً")
|