Spaces:
Runtime error
Runtime error
Commit ·
d4ac261
1
Parent(s): c4ee038
changes
Browse files- 2_gradio.ipynb +59 -12
- app.py +18 -9
2_gradio.ipynb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "code",
|
| 5 |
-
"execution_count":
|
| 6 |
"metadata": {},
|
| 7 |
"outputs": [],
|
| 8 |
"source": [
|
|
@@ -11,7 +11,7 @@
|
|
| 11 |
},
|
| 12 |
{
|
| 13 |
"cell_type": "code",
|
| 14 |
-
"execution_count":
|
| 15 |
"metadata": {},
|
| 16 |
"outputs": [
|
| 17 |
{
|
|
@@ -33,7 +33,7 @@
|
|
| 33 |
},
|
| 34 |
{
|
| 35 |
"cell_type": "code",
|
| 36 |
-
"execution_count":
|
| 37 |
"metadata": {},
|
| 38 |
"outputs": [],
|
| 39 |
"source": [
|
|
@@ -44,7 +44,7 @@
|
|
| 44 |
},
|
| 45 |
{
|
| 46 |
"cell_type": "code",
|
| 47 |
-
"execution_count":
|
| 48 |
"metadata": {},
|
| 49 |
"outputs": [],
|
| 50 |
"source": [
|
|
@@ -62,7 +62,7 @@
|
|
| 62 |
},
|
| 63 |
{
|
| 64 |
"cell_type": "code",
|
| 65 |
-
"execution_count":
|
| 66 |
"metadata": {},
|
| 67 |
"outputs": [],
|
| 68 |
"source": [
|
|
@@ -78,14 +78,61 @@
|
|
| 78 |
},
|
| 79 |
{
|
| 80 |
"cell_type": "code",
|
| 81 |
-
"execution_count":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
"metadata": {},
|
| 83 |
"outputs": [
|
| 84 |
{
|
| 85 |
"name": "stdout",
|
| 86 |
"output_type": "stream",
|
| 87 |
"text": [
|
| 88 |
-
"Running on local URL: http://127.0.0.1:
|
| 89 |
"\n",
|
| 90 |
"To create a public link, set `share=True` in `launch()`.\n"
|
| 91 |
]
|
|
@@ -93,7 +140,7 @@
|
|
| 93 |
{
|
| 94 |
"data": {
|
| 95 |
"text/html": [
|
| 96 |
-
"<div><iframe src=\"http://127.0.0.1:
|
| 97 |
],
|
| 98 |
"text/plain": [
|
| 99 |
"<IPython.core.display.HTML object>"
|
|
@@ -106,7 +153,7 @@
|
|
| 106 |
"data": {
|
| 107 |
"text/plain": []
|
| 108 |
},
|
| 109 |
-
"execution_count":
|
| 110 |
"metadata": {},
|
| 111 |
"output_type": "execute_result"
|
| 112 |
}
|
|
@@ -122,17 +169,17 @@
|
|
| 122 |
"iface = gr.Interface(\n",
|
| 123 |
" fn=greet,\n",
|
| 124 |
" inputs=[\n",
|
| 125 |
-
" gr.Textbox(value='A Christmas present🎄for my 5 years old Kid!!!', label='Describe the product to search')\n",
|
| 126 |
" ],\n",
|
| 127 |
" outputs=[\"dataframe\"],\n",
|
| 128 |
-
" title='
|
| 129 |
")\n",
|
| 130 |
"iface.launch(share=False)"
|
| 131 |
]
|
| 132 |
},
|
| 133 |
{
|
| 134 |
"cell_type": "code",
|
| 135 |
-
"execution_count":
|
| 136 |
"metadata": {},
|
| 137 |
"outputs": [],
|
| 138 |
"source": [
|
|
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "code",
|
| 5 |
+
"execution_count": 1,
|
| 6 |
"metadata": {},
|
| 7 |
"outputs": [],
|
| 8 |
"source": [
|
|
|
|
| 11 |
},
|
| 12 |
{
|
| 13 |
"cell_type": "code",
|
| 14 |
+
"execution_count": 2,
|
| 15 |
"metadata": {},
|
| 16 |
"outputs": [
|
| 17 |
{
|
|
|
|
| 33 |
},
|
| 34 |
{
|
| 35 |
"cell_type": "code",
|
| 36 |
+
"execution_count": 3,
|
| 37 |
"metadata": {},
|
| 38 |
"outputs": [],
|
| 39 |
"source": [
|
|
|
|
| 44 |
},
|
| 45 |
{
|
| 46 |
"cell_type": "code",
|
| 47 |
+
"execution_count": 4,
|
| 48 |
"metadata": {},
|
| 49 |
"outputs": [],
|
| 50 |
"source": [
|
|
|
|
| 62 |
},
|
| 63 |
{
|
| 64 |
"cell_type": "code",
|
| 65 |
+
"execution_count": 5,
|
| 66 |
"metadata": {},
|
| 67 |
"outputs": [],
|
| 68 |
"source": [
|
|
|
|
| 78 |
},
|
| 79 |
{
|
| 80 |
"cell_type": "code",
|
| 81 |
+
"execution_count": 25,
|
| 82 |
+
"metadata": {},
|
| 83 |
+
"outputs": [
|
| 84 |
+
{
|
| 85 |
+
"name": "stdout",
|
| 86 |
+
"output_type": "stream",
|
| 87 |
+
"text": [
|
| 88 |
+
"Running on local URL: http://127.0.0.1:7869\n",
|
| 89 |
+
"\n",
|
| 90 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
| 91 |
+
]
|
| 92 |
+
},
|
| 93 |
+
{
|
| 94 |
+
"data": {
|
| 95 |
+
"text/html": [
|
| 96 |
+
"<div><iframe src=\"http://127.0.0.1:7869/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
| 97 |
+
],
|
| 98 |
+
"text/plain": [
|
| 99 |
+
"<IPython.core.display.HTML object>"
|
| 100 |
+
]
|
| 101 |
+
},
|
| 102 |
+
"metadata": {},
|
| 103 |
+
"output_type": "display_data"
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"data": {
|
| 107 |
+
"text/plain": []
|
| 108 |
+
},
|
| 109 |
+
"execution_count": 25,
|
| 110 |
+
"metadata": {},
|
| 111 |
+
"output_type": "execute_result"
|
| 112 |
+
}
|
| 113 |
+
],
|
| 114 |
+
"source": [
|
| 115 |
+
"with gr.Blocks() as demo:\n",
|
| 116 |
+
"\n",
|
| 117 |
+
" txt = gr.Textbox(value='A Christmas present🎄for my 5 years old Kid!!!', label='What are you looking for?')\n",
|
| 118 |
+
" btn = gr.Button(value=\"Search Product\")\n",
|
| 119 |
+
" state = gr.Dataframe()\n",
|
| 120 |
+
" # btn.click(greet, inputs='text', outputs=['dataframe'])\n",
|
| 121 |
+
" btn.click(greet, [txt], [state])\n",
|
| 122 |
+
"\n",
|
| 123 |
+
"demo.launch(share=False)"
|
| 124 |
+
]
|
| 125 |
+
},
|
| 126 |
+
{
|
| 127 |
+
"cell_type": "code",
|
| 128 |
+
"execution_count": 6,
|
| 129 |
"metadata": {},
|
| 130 |
"outputs": [
|
| 131 |
{
|
| 132 |
"name": "stdout",
|
| 133 |
"output_type": "stream",
|
| 134 |
"text": [
|
| 135 |
+
"Running on local URL: http://127.0.0.1:7860\n",
|
| 136 |
"\n",
|
| 137 |
"To create a public link, set `share=True` in `launch()`.\n"
|
| 138 |
]
|
|
|
|
| 140 |
{
|
| 141 |
"data": {
|
| 142 |
"text/html": [
|
| 143 |
+
"<div><iframe src=\"http://127.0.0.1:7860/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
| 144 |
],
|
| 145 |
"text/plain": [
|
| 146 |
"<IPython.core.display.HTML object>"
|
|
|
|
| 153 |
"data": {
|
| 154 |
"text/plain": []
|
| 155 |
},
|
| 156 |
+
"execution_count": 6,
|
| 157 |
"metadata": {},
|
| 158 |
"output_type": "execute_result"
|
| 159 |
}
|
|
|
|
| 169 |
"iface = gr.Interface(\n",
|
| 170 |
" fn=greet,\n",
|
| 171 |
" inputs=[\n",
|
| 172 |
+
" gr.Textbox(value='A Christmas present🎄for my 5 years old Kid!!!', label='Describe the product to search, then press submit')\n",
|
| 173 |
" ],\n",
|
| 174 |
" outputs=[\"dataframe\"],\n",
|
| 175 |
+
" title='DEMO: Ecommerce Product Recommendation'\n",
|
| 176 |
")\n",
|
| 177 |
"iface.launch(share=False)"
|
| 178 |
]
|
| 179 |
},
|
| 180 |
{
|
| 181 |
"cell_type": "code",
|
| 182 |
+
"execution_count": 7,
|
| 183 |
"metadata": {},
|
| 184 |
"outputs": [],
|
| 185 |
"source": [
|
app.py
CHANGED
|
@@ -33,12 +33,21 @@ import os
|
|
| 33 |
def greet(text1):
|
| 34 |
return search(df, text1)
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
)
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
def greet(text1):
|
| 34 |
return search(df, text1)
|
| 35 |
|
| 36 |
+
with gr.Blocks() as demo:
|
| 37 |
+
txt = gr.Textbox(value='A Christmas present🎄for my 5 years old Kid!!!', label='What are you looking for?')
|
| 38 |
+
btn = gr.Button(value="Search Product")
|
| 39 |
+
state = gr.Dataframe()
|
| 40 |
+
# btn.click(greet, inputs='text', outputs=['dataframe'])
|
| 41 |
+
btn.click(greet, [txt], [state])
|
| 42 |
+
|
| 43 |
+
demo.launch(share=False)
|
| 44 |
+
|
| 45 |
+
# iface = gr.Interface(
|
| 46 |
+
# fn=greet,
|
| 47 |
+
# inputs=[
|
| 48 |
+
# gr.Textbox(value='A Christmas present🎄for my 5 years old Kid!!!', label='Describe the product to search, then press submit')
|
| 49 |
+
# ],
|
| 50 |
+
# outputs=["dataframe"],
|
| 51 |
+
# title='DEMO: Ecommerce Product Recommendation'
|
| 52 |
+
# )
|
| 53 |
+
# iface.launch(share=False)
|