Xquang / app.py
minhduc1503's picture
Create app.py
b3361ae verified
raw
history blame
972 Bytes
import gradio as gr
from PIL import Image
import torch
from transformers import AutoModel, AutoProcessor
# Tải mô hình phân tích ảnh X-quang từ Google
model = AutoModel.from_pretrained("google/cxr-foundation")
processor = AutoProcessor.from_pretrained("google/cxr-foundation")
def du_doan_anh(image):
# Tiền xử lý ảnh
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
return "✅ AI đã phân tích ảnh.\n(Đây là mô hình biểu diễn đặc trưng, bạn có thể huấn luyện thêm.)"
# Tạo giao diện tiếng Việt
app = gr.Interface(
fn=du_doan_anh,
inputs=gr.Image(type="pil", label="📤 Chọn ảnh X-quang"),
outputs=gr.Textbox(label="🤖 Kết quả phân tích"),
title="Phân tích ảnh X-quang bằng AI",
description="Website thử nghiệm phân tích ảnh X-quang bằng mô hình AI huấn luyện sẵn."
)
app.launch()