kuko6 commited on
Commit
abc6dd9
β€’
1 Parent(s): 990061e

changed the UI

Browse files
app.py CHANGED
@@ -3,12 +3,13 @@ import torch
3
  import torchvision.transforms.functional as TF
4
  from model import NeuralNetwork
5
  import json
 
6
 
7
  device = "cuda" if torch.cuda.is_available() else "cpu"
8
 
9
  def pokemon_classifier(inp):
10
  model = NeuralNetwork()
11
- model.load_state_dict(torch.load('model_best.pt', map_location=torch.device(device)))
12
  model.eval()
13
 
14
  with open('labels.json') as f:
@@ -25,5 +26,12 @@ def pokemon_classifier(inp):
25
 
26
  return labels[str(pokemon)]
27
 
28
- demo = gr.Interface(fn=pokemon_classifier, inputs=gr.Image(type="pil"), outputs="text")
 
 
 
 
 
 
 
29
  demo.launch()
 
3
  import torchvision.transforms.functional as TF
4
  from model import NeuralNetwork
5
  import json
6
+ import os
7
 
8
  device = "cuda" if torch.cuda.is_available() else "cpu"
9
 
10
  def pokemon_classifier(inp):
11
  model = NeuralNetwork()
12
+ model.load_state_dict(torch.load("model_best.pt", map_location=torch.device(device)))
13
  model.eval()
14
 
15
  with open('labels.json') as f:
 
26
 
27
  return labels[str(pokemon)]
28
 
29
+ with gr.Blocks() as demo:
30
+ gr.Markdown("# Gen 1 Pokemon classifier")
31
+ with gr.Row():
32
+ inp = gr.Image(type="pil")
33
+ out = gr.Textbox()
34
+ btn = gr.Button("Run")
35
+ btn.click(fn=pokemon_classifier, inputs=inp, outputs=out)
36
+
37
  demo.launch()
images/{Aerodactyl61.jpg β†’ Aerodactyl.jpg} RENAMED
File without changes
images/{Bulbasaur1.jpg β†’ Bulbasaur.jpg} RENAMED
File without changes
images/{Charizard10.jpg β†’ Charizard.jpg} RENAMED
File without changes