Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ from PIL import Image
|
|
2 |
import torch
|
3 |
import gradio as gr
|
4 |
from torchvision.transforms import Compose, Normalize, ToTensor, Resize, CenterCrop
|
|
|
5 |
|
6 |
labels = {0: 'glass',
|
7 |
1: 'metal',
|
@@ -13,6 +14,9 @@ labels = {0: 'glass',
|
|
13 |
inference = torch.load('fine_tune_resnet.pth', map_location=torch.device('cpu'))
|
14 |
inference.eval()
|
15 |
|
|
|
|
|
|
|
16 |
def classifier(image):
|
17 |
test_transform = Compose([
|
18 |
Resize(256),
|
@@ -32,5 +36,7 @@ def classifier(image):
|
|
32 |
|
33 |
iface = gr.Interface(fn=classifier,
|
34 |
inputs=gr.Image(type="pil"),
|
35 |
-
outputs='label'
|
|
|
|
|
36 |
iface.launch(share=True)
|
|
|
2 |
import torch
|
3 |
import gradio as gr
|
4 |
from torchvision.transforms import Compose, Normalize, ToTensor, Resize, CenterCrop
|
5 |
+
from pathlib import Path
|
6 |
|
7 |
labels = {0: 'glass',
|
8 |
1: 'metal',
|
|
|
14 |
inference = torch.load('fine_tune_resnet.pth', map_location=torch.device('cpu'))
|
15 |
inference.eval()
|
16 |
|
17 |
+
|
18 |
+
example = [Path.cwd() / 'cardboard.wp', Path.cwd() / 'plastic.jpg']
|
19 |
+
|
20 |
def classifier(image):
|
21 |
test_transform = Compose([
|
22 |
Resize(256),
|
|
|
36 |
|
37 |
iface = gr.Interface(fn=classifier,
|
38 |
inputs=gr.Image(type="pil"),
|
39 |
+
outputs='label',
|
40 |
+
examples = example,
|
41 |
+
title = 'Garbage Image Classification')
|
42 |
iface.launch(share=True)
|