Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,16 +4,20 @@ from torch import nn
|
|
4 |
import numpy as np
|
5 |
import gradio as gr
|
6 |
import PIL
|
|
|
7 |
|
8 |
# Instantiate classification model
|
9 |
from fastai.vision.all import *
|
10 |
-
model_multi = load_learner('vit_tiny_patch16.pkl')
|
|
|
|
|
11 |
|
12 |
def binary_label(path):
|
13 |
return 'No-anomaly' if (parent_label(path) == 'No-Anomaly') else 'Anomaly'
|
14 |
|
15 |
-
model_binary = load_learner('vit_tiny_patch16_binary.pkl')
|
16 |
-
|
|
|
17 |
# Instantiate segmentation model
|
18 |
from transformers import SegformerFeatureExtractor, SegformerForSemanticSegmentation
|
19 |
from torchvision.transforms import Grayscale
|
|
|
4 |
import numpy as np
|
5 |
import gradio as gr
|
6 |
import PIL
|
7 |
+
from huggingface_hub import from_pretrained_fastai
|
8 |
|
9 |
# Instantiate classification model
|
10 |
from fastai.vision.all import *
|
11 |
+
#model_multi = load_learner('vit_tiny_patch16.pkl')
|
12 |
+
repo_id = "zklee98/vit_tiny_patch16_multi"
|
13 |
+
model_multi = from_pretrained_fastai(repo_id)
|
14 |
|
15 |
def binary_label(path):
|
16 |
return 'No-anomaly' if (parent_label(path) == 'No-Anomaly') else 'Anomaly'
|
17 |
|
18 |
+
#model_binary = load_learner('vit_tiny_patch16_binary.pkl')
|
19 |
+
model_binary = from_pretrained_fastai(repo_id='zklee98/vit_tiny_patch16_binary')
|
20 |
+
|
21 |
# Instantiate segmentation model
|
22 |
from transformers import SegformerFeatureExtractor, SegformerForSemanticSegmentation
|
23 |
from torchvision.transforms import Grayscale
|