Noeies commited on
Commit
22227fc
·
verified ·
1 Parent(s): e4d4984

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -32
app.py DELETED
@@ -1,32 +0,0 @@
1
- import gradio as gr
2
- from transformers import pipeline
3
-
4
- # โหลดโมเดล AI ที่จำภาพได้ (Image Classification)
5
- model = pipeline("image-classification", model="google/vit-base-patch16-224")
6
-
7
- # ฟังก์ชันวิเคราะห์ภาพ
8
- def predict(image):
9
- result = model(image)[0]
10
- label = result['label']
11
- score = round(result['score'] * 100, 2)
12
-
13
- # เพิ่มคำอธิบายง่าย ๆ
14
- description = {
15
- "heart": "หัวใจ ❤️ สูบฉีดเลือดไปทั่วร่างกาย",
16
- "lungs": "ปอด 💨 แลกเปลี่ยนก๊าซในร่างกาย",
17
- "liver": "ตับ 🍷 กำจัดสารพิษและสร้างน้ำดี",
18
- "brain": "สมอง 🧠 ควบคุมการทำงานของร่างกาย"
19
- }.get(label.lower(), "อวัยวะนี้ยังไม่มีข้อมูล")
20
-
21
- return f"🩺 อวัยวะ: {label}\n🔹 ความมั่นใจ: {score}%\n📘 คำอธิบาย: {description}"
22
-
23
- # สร้างเว็บอินเทอร์เฟซ
24
- demo = gr.Interface(
25
- fn=predict,
26
- inputs=gr.Image(type="filepath"),
27
- outputs="text",
28
- title="ระบบเรียนรู้อวัยวะภายในร่างกาย",
29
- description="อัปโหลดภาพอวัยวะ แล้วระบบจะทำนายว่าเป็นส่วนใดของร่างกาย"
30
- )
31
-
32
- demo.launch()