TrentL commited on
Commit
053acd9
·
1 Parent(s): 0025645

Load Model. Gradio UI.

Browse files
Files changed (4) hide show
  1. .gitignore +2 -1
  2. app.py +18 -3
  3. korean.pkl +3 -0
  4. requirements.txt +2 -1
.gitignore CHANGED
@@ -2,7 +2,8 @@
2
  # Edit at https://www.toptal.com/developers/gitignore?templates=python
3
 
4
  # Trent's own python environment
5
- ./venv_soup
 
6
 
7
  ### Python ###
8
  # Byte-compiled / optimized / DLL files
 
2
  # Edit at https://www.toptal.com/developers/gitignore?templates=python
3
 
4
  # Trent's own python environment
5
+ .venv_soup/
6
+ test_img/
7
 
8
  ### Python ###
9
  # Byte-compiled / optimized / DLL files
app.py CHANGED
@@ -1,7 +1,22 @@
1
  import gradio as gr
 
 
 
2
 
3
- def greet(name):
4
- return "Hello there " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  iface.launch()
 
1
  import gradio as gr
2
+ from fastai.text.all import *
3
+ import pathlib
4
+ from pathlib import Path
5
 
6
+ categories = ('Korean','Vietnamese')
 
7
 
8
+ def predict_input_image(img):
9
+ pred,idx,probs = learn_inf.predict(img)
10
+ return dict(zip(categories,map(float,probs)))
11
+
12
+ path = Path()
13
+ temp = pathlib.PosixPath
14
+ pathlib.PosixPath = pathlib.WindowsPath
15
+
16
+ learn_inf = load_learner(path/'korean.pkl')
17
+
18
+ image = gr.inputs.Image(shape=(180,180))
19
+ label = gr.outputs.Label(num_top_classes=2)
20
+
21
+ gr.Interface(fn=predict_input_image, inputs=image, outputs=label,interpretation='default').launch(debug='True')
22
  iface.launch()
korean.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d7edfdaf83ea630cdb884947986b4b014034e8d873f83d1e6c259dd28e2fd96e
3
+ size 46957615
requirements.txt CHANGED
@@ -1 +1,2 @@
1
- gradio
 
 
1
+ gradio
2
+ fastai