| import gradio as gr | |
| from transformers import pipeline | |
| from PIL import Image | |
| # استدعاء النموذج مباشرة من Hugging Face | |
| model_id = "microsoft/llava-med-v1.5-mistral-7b" | |
| # إعداد خط المعالجة (Pipeline) | |
| # ملاحظة: سيتم تحميل النموذج تلقائياً عند التشغيل الأول | |
| pipe = pipeline("image-to-text", model=model_id) | |
| def analyze_radiology(image): | |
| # إرسال الصورة للنموذج وطلب التحليل | |
| result = pipe(image, prompt="USER: <image>\nDescribe this medical image and find any abnormalities. ASSISTANT:") | |
| return result[0]['generated_text'] | |
| # واجهة مستخدم بسيطة ستعمل كـ API لموقعك | |
| demo = gr.Interface( | |
| fn=analyze_radiology, | |
| inputs=gr.Image(type="pil"), | |
| outputs="text", | |
| title="Eldaly Rehab Scholar AI" | |
| ) | |
| demo.launch() |