Sameh891 commited on
Commit
965eda8
·
verified ·
1 Parent(s): d5bffbb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ from PIL import Image
4
+
5
+ # استدعاء النموذج مباشرة من Hugging Face
6
+ model_id = "microsoft/llava-med-v1.5-mistral-7b"
7
+
8
+ # إعداد خط المعالجة (Pipeline)
9
+ # ملاحظة: سيتم تحميل النموذج تلقائياً عند التشغيل الأول
10
+ pipe = pipeline("image-to-text", model=model_id)
11
+
12
+ def analyze_radiology(image):
13
+ # إرسال الصورة للنموذج وطلب التحليل
14
+ result = pipe(image, prompt="USER: <image>\nDescribe this medical image and find any abnormalities. ASSISTANT:")
15
+ return result[0]['generated_text']
16
+
17
+ # واجهة مستخدم بسيطة ستعمل كـ API لموقعك
18
+ demo = gr.Interface(
19
+ fn=analyze_radiology,
20
+ inputs=gr.Image(type="pil"),
21
+ outputs="text",
22
+ title="Eldaly Rehab Scholar AI"
23
+ )
24
+
25
+ demo.launch()