minhduc1503 commited on
Commit
bbf7e34
·
verified ·
1 Parent(s): 2c9e766

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
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 phân tích ảnh X-quang từ Google
7
  model = AutoModel.from_pretrained("google/cxr-foundation")
8
  processor = AutoProcessor.from_pretrained("google/cxr-foundation")
9
 
10
- def du_doan_anh(image):
11
- # Tiền xử lý ảnh
12
  inputs = processor(images=image, return_tensors="pt")
13
  with torch.no_grad():
14
  outputs = model(**inputs)
15
- return "✅ AI đã phân tích ảnh.\n(Đây hình biểu diễn đặc trưng, bạn thể huấn luyện thêm.)"
16
 
17
- # Tạo giao diện tiếng Việt
18
- app = gr.Interface(
19
- fn=du_doan_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"),
22
- title="Phân tích ảnh X-quang bằng AI",
23
- description="Website thử nghiệm phân tích ảnh X-quang bằng hình AI huấn luyện sẵn."
24
  )
25
 
26
- app.launch()
 
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ử ảnh thành công!\n🧠 hình 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()