Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
| 1 |
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
import glob
|
|
|
|
|
|
|
| 4 |
import timm
|
| 5 |
from timm.models import convnext
|
| 6 |
convnext_model = 'convnext_tiny_in22k'
|
| 7 |
model_architecture=timm.create_model(convnext_model)
|
| 8 |
-
|
| 9 |
-
import torch
|
| 10 |
class FastaiConvNext(torch.nn.Module):
|
| 11 |
def __init__(self, original_model):
|
| 12 |
super().__init__()
|
|
@@ -18,14 +18,7 @@ class FastaiConvNext(torch.nn.Module):
|
|
| 18 |
|
| 19 |
model = FastaiConvNext(model_architecture)
|
| 20 |
|
| 21 |
-
|
| 22 |
-
# def hook_func(self, m, i, o): self.stored = o.detach().clone()
|
| 23 |
-
|
| 24 |
-
#learn = load_learner("resnet152_fit_one_cycle_freeze_91acc.pkl", cpu=True)
|
| 25 |
-
|
| 26 |
-
#categories = ('arbanasi', 'filibe', 'gjirokoster', 'iskodra', 'kula', 'kuzguncuk', 'larissa_ampelakia', 'mardin', 'ohrid', 'pristina', 'safranbolu', 'selanik', 'sozopol_suzebolu', 'tiran', 'varna')
|
| 27 |
-
|
| 28 |
-
learn = load_learner("convnext_mixup_0_33.pkl", cpu=True)
|
| 29 |
categories = ('arbanasi', 'filibe', 'gjirokoster', 'iskodra', 'kula', 'kuzguncuk', 'larissa_ampelakia', 'mardin', 'ohrid', 'pristina', 'safranbolu', 'selanik', 'sozopol_suzebolu', 'tiran', 'varna')
|
| 30 |
def classify_img(img):
|
| 31 |
pred,idx,probs=learn.predict(img)
|
|
@@ -33,9 +26,6 @@ def classify_img(img):
|
|
| 33 |
|
| 34 |
image=gr.inputs.Image(shape=(128,128))
|
| 35 |
label=gr.outputs.Label()
|
| 36 |
-
examples_=[]
|
| 37 |
-
for i in glob.glob("valid/**/*.jpg", recursive=True):
|
| 38 |
-
examples_.append(i)
|
| 39 |
|
| 40 |
examples=["filibe-1-1.jpg",
|
| 41 |
"ohrid-3-1.jpg",
|
|
|
|
| 1 |
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
import glob
|
| 4 |
+
|
| 5 |
+
import torch
|
| 6 |
import timm
|
| 7 |
from timm.models import convnext
|
| 8 |
convnext_model = 'convnext_tiny_in22k'
|
| 9 |
model_architecture=timm.create_model(convnext_model)
|
|
|
|
|
|
|
| 10 |
class FastaiConvNext(torch.nn.Module):
|
| 11 |
def __init__(self, original_model):
|
| 12 |
super().__init__()
|
|
|
|
| 18 |
|
| 19 |
model = FastaiConvNext(model_architecture)
|
| 20 |
|
| 21 |
+
learn = load_learner("convnext_mixup_0_33.pkl")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
categories = ('arbanasi', 'filibe', 'gjirokoster', 'iskodra', 'kula', 'kuzguncuk', 'larissa_ampelakia', 'mardin', 'ohrid', 'pristina', 'safranbolu', 'selanik', 'sozopol_suzebolu', 'tiran', 'varna')
|
| 23 |
def classify_img(img):
|
| 24 |
pred,idx,probs=learn.predict(img)
|
|
|
|
| 26 |
|
| 27 |
image=gr.inputs.Image(shape=(128,128))
|
| 28 |
label=gr.outputs.Label()
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
examples=["filibe-1-1.jpg",
|
| 31 |
"ohrid-3-1.jpg",
|