Spaces:
Sleeping
Sleeping
Your Name commited on
Commit ·
1e04f86
1
Parent(s): 8005634
Update crashed car classifier app
Browse files- Fixed model loading in app.py
- Added requirements.txt
- Added .gitignore for venv and temp files
- .gitignore +8 -0
- app.py +17 -4
- car.jpg +0 -0
- crashed.jpg +0 -0
- model.pkl +3 -0
- requirements.txt +2 -0
- test.jpg +0 -0
.gitignore
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
venv/
|
| 2 |
+
.venv/
|
| 3 |
+
__pycache__/
|
| 4 |
+
*.pyc
|
| 5 |
+
.ipynb_checkpoints/
|
| 6 |
+
.gradio/
|
| 7 |
+
*.log
|
| 8 |
+
.DS_Store
|
app.py
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
def
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
def is_crashed_car(x): return x[0].isupper()
|
|
|
|
| 5 |
|
| 6 |
+
categories = ('car', 'crashed car')
|
| 7 |
+
|
| 8 |
+
learn = load_learner('model.pkl')
|
| 9 |
+
learn.remove_cb(ProgressCallback)
|
| 10 |
+
|
| 11 |
+
def classify_image(img):
|
| 12 |
+
pred,idx,probs = learn.predict(img)
|
| 13 |
+
return dict(zip(categories, map(float,probs)))
|
| 14 |
+
|
| 15 |
+
image = gr.Image()
|
| 16 |
+
label = gr.Label()
|
| 17 |
+
examples = ['car.jpg', 'crashed.jpg']
|
| 18 |
+
|
| 19 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 20 |
+
intf.launch(inline=False)
|
car.jpg
ADDED
|
crashed.jpg
ADDED
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2b8b6b84ad2f1995c84f43ff05abb51b198f6b4899f5ca3fd420a36653646659
|
| 3 |
+
size 46959111
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastai
|
| 2 |
+
gradio
|
test.jpg
ADDED
|