init
Browse files- app.py +19 -0
- environment.yml +9 -0
- requirements.txt +5 -0
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
|
| 4 |
+
def is_cat(x): return x[0].isupper()
|
| 5 |
+
|
| 6 |
+
learn = load_learner('model.pkl')
|
| 7 |
+
|
| 8 |
+
categories = ('kissing', 'not_kissing')
|
| 9 |
+
|
| 10 |
+
def classify_image(img):
|
| 11 |
+
pred,idx,probs = learn.predict(img)
|
| 12 |
+
return dict(zip(categories, map(float,probs)))
|
| 13 |
+
|
| 14 |
+
image = gr.inputs.Image(shape=(192,192))
|
| 15 |
+
label = gr.outputs.Label()
|
| 16 |
+
#examples = ['cat.jpeg', 'dog.jpeg', 'catdog.jpeg']
|
| 17 |
+
|
| 18 |
+
iface = gr.Interface(fn=classify_image, inputs=image, outputs=label) # examples=examples)
|
| 19 |
+
iface.launch()
|
environment.yml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: minimal
|
| 2 |
+
channels:
|
| 3 |
+
- defaults
|
| 4 |
+
dependencies:
|
| 5 |
+
- ipywidgets
|
| 6 |
+
- pip:
|
| 7 |
+
- gradio
|
| 8 |
+
- fastai
|
| 9 |
+
prefix: ~/miniconda3/envs/minimal
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastai
|
| 2 |
+
torch
|
| 3 |
+
gradio
|
| 4 |
+
numpy
|
| 5 |
+
pandas
|