| 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 = 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 لتشغيل النظام") |
|
|
| |
| st.markdown("---") |
| st.caption("Accudent AI - Smart Dental Diagnostics 🦷") |