Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,18 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import
|
3 |
import torch
|
4 |
from PIL import Image
|
5 |
|
6 |
model_name = 'e1010101/vit-384-tongue-image'
|
7 |
-
processor =
|
8 |
-
model = AutoModelForImageClassification.from_pretrained(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
def classify_image(image):
|
11 |
inputs = processor(images=image, return_tensors="pt")
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoImageProcessor, AutoModelForImageClassification
|
3 |
import torch
|
4 |
from PIL import Image
|
5 |
|
6 |
model_name = 'e1010101/vit-384-tongue-image'
|
7 |
+
processor = AutoImageProcessor.from_pretrained("google/vit-base-patch16-384")
|
8 |
+
model = AutoModelForImageClassification.from_pretrained(
|
9 |
+
model_name,
|
10 |
+
num_labels=3,
|
11 |
+
problem_type="multi_label_classification",
|
12 |
+
ignore_mismatched_sizes=True,
|
13 |
+
id2label={0: 'Crack', 1: 'Red-Dots', 2: 'Toothmark'},
|
14 |
+
label2id={'Crack': 0, 'Red-Dots': 1, 'Toothmark': 2}
|
15 |
+
)
|
16 |
|
17 |
def classify_image(image):
|
18 |
inputs = processor(images=image, return_tensors="pt")
|