File size: 865 Bytes
965eda8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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()