try 11
Browse files- Untitled-1.ipynb +50 -0
- app.py +18 -0
Untitled-1.ipynb
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [
|
8 |
+
{
|
9 |
+
"name": "stderr",
|
10 |
+
"output_type": "stream",
|
11 |
+
"text": [
|
12 |
+
"/home/sfilipp1/mambaforge/lib/python3.9/site-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: libc10_cuda.so: cannot open shared object file: No such file or directory\n",
|
13 |
+
" warn(f\"Failed to load image Python extension: {e}\")\n"
|
14 |
+
]
|
15 |
+
}
|
16 |
+
],
|
17 |
+
"source": [
|
18 |
+
"from fastai.vision.all import *\n",
|
19 |
+
"import gradio as gr"
|
20 |
+
]
|
21 |
+
}
|
22 |
+
],
|
23 |
+
"metadata": {
|
24 |
+
"kernelspec": {
|
25 |
+
"display_name": "Python 3.9.13 ('base')",
|
26 |
+
"language": "python",
|
27 |
+
"name": "python3"
|
28 |
+
},
|
29 |
+
"language_info": {
|
30 |
+
"codemirror_mode": {
|
31 |
+
"name": "ipython",
|
32 |
+
"version": 3
|
33 |
+
},
|
34 |
+
"file_extension": ".py",
|
35 |
+
"mimetype": "text/x-python",
|
36 |
+
"name": "python",
|
37 |
+
"nbconvert_exporter": "python",
|
38 |
+
"pygments_lexer": "ipython3",
|
39 |
+
"version": "3.9.13"
|
40 |
+
},
|
41 |
+
"orig_nbformat": 4,
|
42 |
+
"vscode": {
|
43 |
+
"interpreter": {
|
44 |
+
"hash": "4895cda3d695abceef9008ee3368d5a344043d028ca3fa312c002f1362366dd1"
|
45 |
+
}
|
46 |
+
}
|
47 |
+
},
|
48 |
+
"nbformat": 4,
|
49 |
+
"nbformat_minor": 2
|
50 |
+
}
|
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
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 |
+
|
17 |
+
intf = gr.Interface(fn=classify_image,inputs=image,outputs=label)
|
18 |
+
intf.launch(inline=False)
|