Spaces:
Build error
Build error
Create app.py
Browse files
app.py
CHANGED
@@ -3,24 +3,24 @@ from PIL import Image
|
|
3 |
import torch
|
4 |
from transformers import AutoModel, AutoProcessor
|
5 |
|
6 |
-
# Tải mô hình
|
7 |
model = AutoModel.from_pretrained("google/cxr-foundation")
|
8 |
processor = AutoProcessor.from_pretrained("google/cxr-foundation")
|
9 |
|
10 |
-
|
11 |
-
|
12 |
inputs = processor(images=image, return_tensors="pt")
|
13 |
with torch.no_grad():
|
14 |
outputs = model(**inputs)
|
15 |
-
return "✅ AI đã
|
16 |
|
17 |
-
#
|
18 |
-
|
19 |
-
fn=
|
20 |
inputs=gr.Image(type="pil", label="📤 Chọn ảnh X-quang"),
|
21 |
-
outputs=gr.Textbox(label="
|
22 |
-
title="
|
23 |
-
description="
|
24 |
)
|
25 |
|
26 |
-
|
|
|
3 |
import torch
|
4 |
from transformers import AutoModel, AutoProcessor
|
5 |
|
6 |
+
# Tải mô hình AI của Google dùng cho ảnh X-quang
|
7 |
model = AutoModel.from_pretrained("google/cxr-foundation")
|
8 |
processor = AutoProcessor.from_pretrained("google/cxr-foundation")
|
9 |
|
10 |
+
# Hàm xử lý khi người dùng tải ảnh lên
|
11 |
+
def phan_tich_anh(image):
|
12 |
inputs = processor(images=image, return_tensors="pt")
|
13 |
with torch.no_grad():
|
14 |
outputs = model(**inputs)
|
15 |
+
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."
|
16 |
|
17 |
+
# Giao diện tiếng Việt
|
18 |
+
giao_dien = gr.Interface(
|
19 |
+
fn=phan_tich_anh,
|
20 |
inputs=gr.Image(type="pil", label="📤 Chọn ảnh X-quang"),
|
21 |
+
outputs=gr.Textbox(label="📋 Kết quả phân tích từ AI"),
|
22 |
+
title="🧠 Ứng dụng AI phân tích ảnh X-quang",
|
23 |
+
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ế."
|
24 |
)
|
25 |
|
26 |
+
giao_dien.launch()
|