zach commited on
Commit ·
0faf394
1
Parent(s): 65f8545
first test model complete and tested locally
Browse files- README.md +20 -0
- app.py +15 -3
- cat.jpeg +0 -0
- catdog.jpeg +0 -0
- dog.jpeg +0 -0
- environment.yml +9 -0
README.md
CHANGED
|
@@ -11,3 +11,23 @@ license: apache-2.0
|
|
| 11 |
---
|
| 12 |
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
| 14 |
+
|
| 15 |
+
```bash
|
| 16 |
+
conda env create --force -f environment.yml
|
| 17 |
+
```
|
| 18 |
+
then
|
| 19 |
+
```
|
| 20 |
+
pip install -r requirements.txt
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
but it might be better to run
|
| 24 |
+
```
|
| 25 |
+
~/miniconda3/envs/atak_peer/bin/pip install -r requirements.txt
|
| 26 |
+
```
|
| 27 |
+
|
| 28 |
+
and also use python from here:
|
| 29 |
+
```
|
| 30 |
+
~/miniconda3/envs/atak_peer/bin/python3
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
|
app.py
CHANGED
|
@@ -1,7 +1,19 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
def
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
iface.launch()
|
|
|
|
| 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 = ('Dog', 'Cat')
|
| 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()
|
cat.jpeg
ADDED
|
catdog.jpeg
ADDED
|
dog.jpeg
ADDED
|
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
|