Spaces:
Runtime error
Runtime error
Héctor Tarrido-Picart
commited on
Commit
•
c91e778
1
Parent(s):
da15c63
my first real app
Browse filesadd model, app.py, example photos, jupyter notebook
- .idea/.gitignore +3 -0
- .idea/inspectionProfiles/profiles_settings.xml +6 -0
- .idea/misc.xml +4 -0
- .idea/modules.xml +8 -0
- .idea/powerline-down-id.iml +8 -0
- .idea/vcs.xml +6 -0
- .ipynb_checkpoints/powerline app-checkpoint.ipynb +125 -0
- app.py +22 -0
- model.pkl +3 -0
- powerline app.ipynb +254 -0
- powerline_down.jpg +0 -0
- powerline_tree.jpg +0 -0
.idea/.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
# Default ignored files
|
2 |
+
/shelf/
|
3 |
+
/workspace.xml
|
.idea/inspectionProfiles/profiles_settings.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="InspectionProjectProfileManager">
|
2 |
+
<settings>
|
3 |
+
<option name="USE_PROJECT_PROFILE" value="false" />
|
4 |
+
<version value="1.0" />
|
5 |
+
</settings>
|
6 |
+
</component>
|
.idea/misc.xml
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (powerline-down-id)" project-jdk-type="Python SDK" />
|
4 |
+
</project>
|
.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectModuleManager">
|
4 |
+
<modules>
|
5 |
+
<module fileurl="file://$PROJECT_DIR$/.idea/powerline-down-id.iml" filepath="$PROJECT_DIR$/.idea/powerline-down-id.iml" />
|
6 |
+
</modules>
|
7 |
+
</component>
|
8 |
+
</project>
|
.idea/powerline-down-id.iml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<module type="PYTHON_MODULE" version="4">
|
3 |
+
<component name="NewModuleRootManager">
|
4 |
+
<content url="file://$MODULE_DIR$" />
|
5 |
+
<orderEntry type="inheritedJdk" />
|
6 |
+
<orderEntry type="sourceFolder" forTests="false" />
|
7 |
+
</component>
|
8 |
+
</module>
|
.idea/vcs.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="VcsDirectoryMappings">
|
4 |
+
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
5 |
+
</component>
|
6 |
+
</project>
|
.ipynb_checkpoints/powerline app-checkpoint.ipynb
ADDED
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"id": "250fcb86",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"#|default_exp app"
|
11 |
+
]
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"cell_type": "markdown",
|
15 |
+
"id": "ea967051",
|
16 |
+
"metadata": {},
|
17 |
+
"source": [
|
18 |
+
"# Powerline app"
|
19 |
+
]
|
20 |
+
},
|
21 |
+
{
|
22 |
+
"cell_type": "code",
|
23 |
+
"execution_count": 12,
|
24 |
+
"id": "3f54ef95",
|
25 |
+
"metadata": {},
|
26 |
+
"outputs": [
|
27 |
+
{
|
28 |
+
"ename": "ModuleNotFoundError",
|
29 |
+
"evalue": "No module named 'gradio'",
|
30 |
+
"output_type": "error",
|
31 |
+
"traceback": [
|
32 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
33 |
+
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
|
34 |
+
"Cell \u001b[0;32mIn[12], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m#| export\u001b[39;00m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mfastai\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mvision\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mall\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;241m*\u001b[39m\n\u001b[0;32m----> 3\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mgradio\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mgr\u001b[39;00m\n",
|
35 |
+
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'gradio'"
|
36 |
+
]
|
37 |
+
}
|
38 |
+
],
|
39 |
+
"source": [
|
40 |
+
"#| export\n",
|
41 |
+
"from fastai.vision.all import *\n",
|
42 |
+
"import gradio as gr"
|
43 |
+
]
|
44 |
+
},
|
45 |
+
{
|
46 |
+
"cell_type": "code",
|
47 |
+
"execution_count": 8,
|
48 |
+
"id": "d25179ca",
|
49 |
+
"metadata": {},
|
50 |
+
"outputs": [],
|
51 |
+
"source": [
|
52 |
+
"#| export\n",
|
53 |
+
"learn = load_learner('model.pkl')"
|
54 |
+
]
|
55 |
+
},
|
56 |
+
{
|
57 |
+
"cell_type": "code",
|
58 |
+
"execution_count": 9,
|
59 |
+
"id": "d752f05b",
|
60 |
+
"metadata": {},
|
61 |
+
"outputs": [],
|
62 |
+
"source": [
|
63 |
+
"#| export\n",
|
64 |
+
"labels = learn.dls.vocab\n",
|
65 |
+
"\n",
|
66 |
+
"def predict(img):\n",
|
67 |
+
" img = PILImage.create(img)\n",
|
68 |
+
" pred,pred_idx,probs = learn.predict(img)\n",
|
69 |
+
" return {labels[i]: float(probs[i]) for i in range(len(labels))}"
|
70 |
+
]
|
71 |
+
},
|
72 |
+
{
|
73 |
+
"cell_type": "code",
|
74 |
+
"execution_count": 10,
|
75 |
+
"id": "80d55893",
|
76 |
+
"metadata": {},
|
77 |
+
"outputs": [
|
78 |
+
{
|
79 |
+
"ename": "NameError",
|
80 |
+
"evalue": "name 'gr' is not defined",
|
81 |
+
"output_type": "error",
|
82 |
+
"traceback": [
|
83 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
84 |
+
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
85 |
+
"Cell \u001b[0;32mIn[10], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mgr\u001b[49m\u001b[38;5;241m.\u001b[39mInterface(fn\u001b[38;5;241m=\u001b[39mpredict, inputs\u001b[38;5;241m=\u001b[39mgr\u001b[38;5;241m.\u001b[39minputs\u001b[38;5;241m.\u001b[39mImage(shape\u001b[38;5;241m=\u001b[39m(\u001b[38;5;241m512\u001b[39m, \u001b[38;5;241m512\u001b[39m)), outputs\u001b[38;5;241m=\u001b[39mgr\u001b[38;5;241m.\u001b[39moutputs\u001b[38;5;241m.\u001b[39mLabel(num_top_classes\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m3\u001b[39m))\u001b[38;5;241m.\u001b[39mlaunch(share\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n",
|
86 |
+
"\u001b[0;31mNameError\u001b[0m: name 'gr' is not defined"
|
87 |
+
]
|
88 |
+
}
|
89 |
+
],
|
90 |
+
"source": [
|
91 |
+
"#| export\n",
|
92 |
+
"gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)"
|
93 |
+
]
|
94 |
+
},
|
95 |
+
{
|
96 |
+
"cell_type": "code",
|
97 |
+
"execution_count": null,
|
98 |
+
"id": "9e304d06",
|
99 |
+
"metadata": {},
|
100 |
+
"outputs": [],
|
101 |
+
"source": []
|
102 |
+
}
|
103 |
+
],
|
104 |
+
"metadata": {
|
105 |
+
"kernelspec": {
|
106 |
+
"display_name": "Python 3 (ipykernel)",
|
107 |
+
"language": "python",
|
108 |
+
"name": "python3"
|
109 |
+
},
|
110 |
+
"language_info": {
|
111 |
+
"codemirror_mode": {
|
112 |
+
"name": "ipython",
|
113 |
+
"version": 3
|
114 |
+
},
|
115 |
+
"file_extension": ".py",
|
116 |
+
"mimetype": "text/x-python",
|
117 |
+
"name": "python",
|
118 |
+
"nbconvert_exporter": "python",
|
119 |
+
"pygments_lexer": "ipython3",
|
120 |
+
"version": "3.8.17"
|
121 |
+
}
|
122 |
+
},
|
123 |
+
"nbformat": 4,
|
124 |
+
"nbformat_minor": 5
|
125 |
+
}
|
app.py
CHANGED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
learn = load_learner('model.pkl')
|
5 |
+
|
6 |
+
categories = ['palm tree down', 'powerline down', 'powerline arcing']
|
7 |
+
|
8 |
+
def predict(img):
|
9 |
+
img = PILImage.create(img)
|
10 |
+
pred,idx,probs = learn.predict(img)
|
11 |
+
return dict(zip(categories, map(float, probs)))
|
12 |
+
|
13 |
+
images = gr.inputs.Image(shape=(512, 512))
|
14 |
+
labels = gr.outputs.Label()
|
15 |
+
examples = ['powerline_down.jpg', 'powerline_tree.jpg']
|
16 |
+
|
17 |
+
intf = gr.Interface(fn=predict,
|
18 |
+
inputs=images,
|
19 |
+
outputs=labels,
|
20 |
+
examples=examples)
|
21 |
+
|
22 |
+
intf.launch(share=True)
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dfe05575ec947c1345d83808c70c04029534976514e44eff13c15d0fd7051e37
|
3 |
+
size 46958501
|
powerline app.ipynb
ADDED
@@ -0,0 +1,254 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"id": "250fcb86",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"#|default_exp app"
|
11 |
+
]
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"cell_type": "markdown",
|
15 |
+
"id": "ea967051",
|
16 |
+
"metadata": {},
|
17 |
+
"source": [
|
18 |
+
"# Powerline app"
|
19 |
+
]
|
20 |
+
},
|
21 |
+
{
|
22 |
+
"cell_type": "code",
|
23 |
+
"execution_count": 3,
|
24 |
+
"id": "3f54ef95",
|
25 |
+
"metadata": {},
|
26 |
+
"outputs": [],
|
27 |
+
"source": [
|
28 |
+
"#|export\n",
|
29 |
+
"from fastai.vision.all import *\n",
|
30 |
+
"import gradio as gr"
|
31 |
+
]
|
32 |
+
},
|
33 |
+
{
|
34 |
+
"cell_type": "code",
|
35 |
+
"execution_count": 4,
|
36 |
+
"id": "d25179ca",
|
37 |
+
"metadata": {},
|
38 |
+
"outputs": [],
|
39 |
+
"source": [
|
40 |
+
"#|export\n",
|
41 |
+
"learn = load_learner('model.pkl')"
|
42 |
+
]
|
43 |
+
},
|
44 |
+
{
|
45 |
+
"cell_type": "code",
|
46 |
+
"execution_count": 9,
|
47 |
+
"id": "d752f05b",
|
48 |
+
"metadata": {},
|
49 |
+
"outputs": [],
|
50 |
+
"source": [
|
51 |
+
"#|export\n",
|
52 |
+
"categories = ['palm tree down', 'powerline down', 'powerline arcing']\n",
|
53 |
+
"\n",
|
54 |
+
"def predict(img):\n",
|
55 |
+
" img = PILImage.create(img)\n",
|
56 |
+
" pred,idx,probs = learn.predict(img)\n",
|
57 |
+
" return dict(zip(categories, map(float, probs)))"
|
58 |
+
]
|
59 |
+
},
|
60 |
+
{
|
61 |
+
"cell_type": "code",
|
62 |
+
"execution_count": 10,
|
63 |
+
"id": "80d55893",
|
64 |
+
"metadata": {
|
65 |
+
"scrolled": false
|
66 |
+
},
|
67 |
+
"outputs": [
|
68 |
+
{
|
69 |
+
"name": "stderr",
|
70 |
+
"output_type": "stream",
|
71 |
+
"text": [
|
72 |
+
"/Users/hectortarrido-picart/mambaforge/envs/powerline-down-id/lib/python3.8/site-packages/gradio/inputs.py:257: UserWarning: Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components\n",
|
73 |
+
" warnings.warn(\n",
|
74 |
+
"/Users/hectortarrido-picart/mambaforge/envs/powerline-down-id/lib/python3.8/site-packages/gradio/deprecation.py:40: UserWarning: `optional` parameter is deprecated, and it has no effect\n",
|
75 |
+
" warnings.warn(value)\n",
|
76 |
+
"/Users/hectortarrido-picart/mambaforge/envs/powerline-down-id/lib/python3.8/site-packages/gradio/outputs.py:197: UserWarning: Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components\n",
|
77 |
+
" warnings.warn(\n",
|
78 |
+
"/Users/hectortarrido-picart/mambaforge/envs/powerline-down-id/lib/python3.8/site-packages/gradio/deprecation.py:40: UserWarning: The 'type' parameter has been deprecated. Use the Number component instead.\n",
|
79 |
+
" warnings.warn(value)\n"
|
80 |
+
]
|
81 |
+
},
|
82 |
+
{
|
83 |
+
"name": "stdout",
|
84 |
+
"output_type": "stream",
|
85 |
+
"text": [
|
86 |
+
"Running on local URL: http://127.0.0.1:7863\n",
|
87 |
+
"Running on public URL: https://364e6970d9ec07c222.gradio.live\n",
|
88 |
+
"\n",
|
89 |
+
"This share link expires in 72 hours. For free permanent hosting and GPU upgrades (NEW!), check out Spaces: https://huggingface.co/spaces\n"
|
90 |
+
]
|
91 |
+
},
|
92 |
+
{
|
93 |
+
"data": {
|
94 |
+
"text/html": [
|
95 |
+
"<div><iframe src=\"https://364e6970d9ec07c222.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
96 |
+
],
|
97 |
+
"text/plain": [
|
98 |
+
"<IPython.core.display.HTML object>"
|
99 |
+
]
|
100 |
+
},
|
101 |
+
"metadata": {},
|
102 |
+
"output_type": "display_data"
|
103 |
+
},
|
104 |
+
{
|
105 |
+
"data": {
|
106 |
+
"text/plain": []
|
107 |
+
},
|
108 |
+
"execution_count": 10,
|
109 |
+
"metadata": {},
|
110 |
+
"output_type": "execute_result"
|
111 |
+
},
|
112 |
+
{
|
113 |
+
"data": {
|
114 |
+
"text/html": [
|
115 |
+
"\n",
|
116 |
+
"<style>\n",
|
117 |
+
" /* Turns off some styling */\n",
|
118 |
+
" progress {\n",
|
119 |
+
" /* gets rid of default border in Firefox and Opera. */\n",
|
120 |
+
" border: none;\n",
|
121 |
+
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
122 |
+
" background-size: auto;\n",
|
123 |
+
" }\n",
|
124 |
+
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
125 |
+
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
126 |
+
" }\n",
|
127 |
+
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
128 |
+
" background: #F44336;\n",
|
129 |
+
" }\n",
|
130 |
+
"</style>\n"
|
131 |
+
],
|
132 |
+
"text/plain": [
|
133 |
+
"<IPython.core.display.HTML object>"
|
134 |
+
]
|
135 |
+
},
|
136 |
+
"metadata": {},
|
137 |
+
"output_type": "display_data"
|
138 |
+
},
|
139 |
+
{
|
140 |
+
"data": {
|
141 |
+
"text/html": [],
|
142 |
+
"text/plain": [
|
143 |
+
"<IPython.core.display.HTML object>"
|
144 |
+
]
|
145 |
+
},
|
146 |
+
"metadata": {},
|
147 |
+
"output_type": "display_data"
|
148 |
+
},
|
149 |
+
{
|
150 |
+
"data": {
|
151 |
+
"text/html": [
|
152 |
+
"\n",
|
153 |
+
"<style>\n",
|
154 |
+
" /* Turns off some styling */\n",
|
155 |
+
" progress {\n",
|
156 |
+
" /* gets rid of default border in Firefox and Opera. */\n",
|
157 |
+
" border: none;\n",
|
158 |
+
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
159 |
+
" background-size: auto;\n",
|
160 |
+
" }\n",
|
161 |
+
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
162 |
+
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
163 |
+
" }\n",
|
164 |
+
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
165 |
+
" background: #F44336;\n",
|
166 |
+
" }\n",
|
167 |
+
"</style>\n"
|
168 |
+
],
|
169 |
+
"text/plain": [
|
170 |
+
"<IPython.core.display.HTML object>"
|
171 |
+
]
|
172 |
+
},
|
173 |
+
"metadata": {},
|
174 |
+
"output_type": "display_data"
|
175 |
+
},
|
176 |
+
{
|
177 |
+
"data": {
|
178 |
+
"text/html": [],
|
179 |
+
"text/plain": [
|
180 |
+
"<IPython.core.display.HTML object>"
|
181 |
+
]
|
182 |
+
},
|
183 |
+
"metadata": {},
|
184 |
+
"output_type": "display_data"
|
185 |
+
}
|
186 |
+
],
|
187 |
+
"source": [
|
188 |
+
"#|export\n",
|
189 |
+
"images = gr.inputs.Image(shape=(512, 512))\n",
|
190 |
+
"labels = gr.outputs.Label()\n",
|
191 |
+
"examples = ['powerline_down.jpg', 'powerline_tree.jpg']\n",
|
192 |
+
"\n",
|
193 |
+
"intf = gr.Interface(fn=predict, \n",
|
194 |
+
" inputs=images, \n",
|
195 |
+
" outputs=labels,\n",
|
196 |
+
" examples=examples)\n",
|
197 |
+
"\n",
|
198 |
+
"intf.launch(share=True)"
|
199 |
+
]
|
200 |
+
},
|
201 |
+
{
|
202 |
+
"cell_type": "code",
|
203 |
+
"execution_count": 13,
|
204 |
+
"id": "edcc9a51",
|
205 |
+
"metadata": {},
|
206 |
+
"outputs": [
|
207 |
+
{
|
208 |
+
"ename": "ImportError",
|
209 |
+
"evalue": "cannot import name 'notebook2script' from 'nbdev.export' (/Users/hectortarrido-picart/mambaforge/envs/powerline-down-id/lib/python3.8/site-packages/nbdev/export.py)",
|
210 |
+
"output_type": "error",
|
211 |
+
"traceback": [
|
212 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
213 |
+
"\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)",
|
214 |
+
"Cell \u001b[0;32mIn[13], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mnbdev\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mexport\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m notebook2script\n\u001b[1;32m 2\u001b[0m notebook2script(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mpowerline app.ipynb\u001b[39m\u001b[38;5;124m'\u001b[39m)\n",
|
215 |
+
"\u001b[0;31mImportError\u001b[0m: cannot import name 'notebook2script' from 'nbdev.export' (/Users/hectortarrido-picart/mambaforge/envs/powerline-down-id/lib/python3.8/site-packages/nbdev/export.py)"
|
216 |
+
]
|
217 |
+
}
|
218 |
+
],
|
219 |
+
"source": [
|
220 |
+
"from nbdev.export import notebook2script\n",
|
221 |
+
"notebook2script('powerline app.ipynb')"
|
222 |
+
]
|
223 |
+
},
|
224 |
+
{
|
225 |
+
"cell_type": "code",
|
226 |
+
"execution_count": null,
|
227 |
+
"id": "47733e23",
|
228 |
+
"metadata": {},
|
229 |
+
"outputs": [],
|
230 |
+
"source": []
|
231 |
+
}
|
232 |
+
],
|
233 |
+
"metadata": {
|
234 |
+
"kernelspec": {
|
235 |
+
"display_name": "Python 3 (ipykernel)",
|
236 |
+
"language": "python",
|
237 |
+
"name": "python3"
|
238 |
+
},
|
239 |
+
"language_info": {
|
240 |
+
"codemirror_mode": {
|
241 |
+
"name": "ipython",
|
242 |
+
"version": 3
|
243 |
+
},
|
244 |
+
"file_extension": ".py",
|
245 |
+
"mimetype": "text/x-python",
|
246 |
+
"name": "python",
|
247 |
+
"nbconvert_exporter": "python",
|
248 |
+
"pygments_lexer": "ipython3",
|
249 |
+
"version": "3.8.17"
|
250 |
+
}
|
251 |
+
},
|
252 |
+
"nbformat": 4,
|
253 |
+
"nbformat_minor": 5
|
254 |
+
}
|
powerline_down.jpg
ADDED
powerline_tree.jpg
ADDED