test2 / app.py
Doctor21's picture
Update app.py
d1d4622 verified
Raw
History Blame Contribute Delete
2.5 kB
import streamlit as st
import google.generativeai as genai
from PIL import Image
# إعداد الصفحة
st.set_page_config(page_title="Accudent AI", page_icon="🦷", layout="centered")
st.title("🦷 Accudent AI: Dental Analysis")
st.write("ارفع صورة الأشعة (X-ray) أو الحالة الإكلينيكية للتحليل الفوري")
# API Key
api_key = st.text_input("Enter your Gemini API Key:", type="password")
if api_key:
try:
genai.configure(api_key=api_key)
# رفع الصورة
uploaded_file = st.file_uploader(
"اختار صورة الأشعة (JPG, PNG)...",
type=["jpg", "jpeg", "png"]
)
if uploaded_file is not None:
image = Image.open(uploaded_file).convert("RGB")
st.image(image, caption="الحالة المرفوعة", use_container_width=True)
if st.button("بدء التحليل الذكي ✨"):
with st.spinner("جاري التحليل..."):
try:
# ✅ موديل مضمون
model = genai.GenerativeModel("gemini-1.5-pro")
prompt = """
You are a professional Dental Radiologist.
Analyze this dental X-ray:
- Tooth identification
- Root canal condition
- Any infection or radiolucency
- Restorations or caries
- Suggested treatment
Give a short, clear clinical report.
"""
response = model.generate_content([prompt, image])
st.success("✅ تم التحليل بنجاح")
st.subheader("📋 التقرير:")
if hasattr(response, "text"):
st.write(response.text)
else:
st.write("No response text received.")
except Exception as e:
st.error("❌ خطأ أثناء التحليل")
st.code(str(e))
except Exception as e:
st.error("❌ مشكلة في API Key")
st.code(str(e))
else:
st.warning("من فضلك أدخل الـ API Key لتشغيل النظام")
# Footer
st.markdown("---")
st.caption("Accudent AI - Smart Dental Diagnostics 🦷")