import gradio as gr from PIL import Image import torch from transformers import AutoModel, AutoProcessor # Tải mô hình AI của Google dùng cho ảnh X-quang model = AutoModel.from_pretrained("google/cxr-foundation") processor = AutoProcessor.from_pretrained("google/cxr-foundation") # Hàm xử lý khi người dùng tải ảnh lên def phan_tich_anh(image): inputs = processor(images=image, return_tensors="pt") with torch.no_grad(): outputs = model(**inputs) return "✅ AI đã xử lý ảnh thành công!\n🧠 Mô hình có thể được huấn luyện thêm với dữ liệu riêng của bạn." # Giao diện tiếng Việt giao_dien = gr.Interface( fn=phan_tich_anh, inputs=gr.Image(type="pil", label="📤 Chọn ảnh X-quang"), outputs=gr.Textbox(label="📋 Kết quả phân tích từ AI"), title="🧠 Ứng dụng AI phân tích ảnh X-quang", description="Ứng dụng thử nghiệm AI phân tích ảnh X-quang.\nChức năng đang được hoàn thiện. Không thay thế cho chẩn đoán y tế." ) giao_dien.launch()