- app.py +15 -13
- requirements.txt +0 -1
app.py
CHANGED
|
@@ -1,19 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from fastai.vision.widgets import *
|
| 3 |
from fastai.vision.all import *
|
| 4 |
-
import skimage
|
| 5 |
|
| 6 |
learn = load_learner('export.pkl')
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
| 15 |
examples = ['tank_1.jpg', 'tank_2.jfif', 'photos.jfif']
|
| 16 |
-
# interpretation='default'
|
| 17 |
-
# enable_queue=True
|
| 18 |
|
| 19 |
-
gr.Interface(fn=
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
# from fastai.vision.widgets import *
|
| 3 |
from fastai.vision.all import *
|
| 4 |
+
# import skimage
|
| 5 |
|
| 6 |
learn = load_learner('export.pkl')
|
| 7 |
+
|
| 8 |
+
# Cell
|
| 9 |
+
categories = ('Tank', 'No-Tank')
|
| 10 |
+
|
| 11 |
+
def classify_image(img):
|
| 12 |
+
pred,idx,probs = learn.predict(img)
|
| 13 |
+
return dict(zip(categories, map(float,probs)))
|
| 14 |
+
|
| 15 |
+
# Cell
|
| 16 |
+
image = gr.inputs.Image(shape=(256, 256))
|
| 17 |
+
label = gr.outputs.Label()
|
| 18 |
examples = ['tank_1.jpg', 'tank_2.jfif', 'photos.jfif']
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 21 |
+
intf.launch(inline=False)
|
requirements.txt
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
fastai==2.7.5
|
| 2 |
fastcore==1.4.5
|
| 3 |
-
scikit-image
|
| 4 |
ipywidgets
|
|
|
|
| 1 |
fastai==2.7.5
|
| 2 |
fastcore==1.4.5
|
|
|
|
| 3 |
ipywidgets
|