Michelangiolo commited on
Commit
f11cbf5
·
1 Parent(s): c1c573b
Files changed (2) hide show
  1. 2_gradio.ipynb +12 -8
  2. app.py +7 -2
2_gradio.ipynb CHANGED
@@ -78,14 +78,14 @@
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
  ]
@@ -93,7 +93,7 @@
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>"
@@ -106,16 +106,20 @@
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",
 
78
  },
79
  {
80
  "cell_type": "code",
81
+ "execution_count": 55,
82
  "metadata": {},
83
  "outputs": [
84
  {
85
  "name": "stdout",
86
  "output_type": "stream",
87
  "text": [
88
+ "Running on local URL: http://127.0.0.1:7894\n",
89
  "\n",
90
  "To create a public link, set `share=True` in `launch()`.\n"
91
  ]
 
93
  {
94
  "data": {
95
  "text/html": [
96
+ "<div><iframe src=\"http://127.0.0.1:7894/\" 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>"
 
106
  "data": {
107
  "text/plain": []
108
  },
109
+ "execution_count": 55,
110
  "metadata": {},
111
  "output_type": "execute_result"
112
  }
113
  ],
114
  "source": [
115
+ "with gr.Blocks(theme=gr.themes.Soft(primary_hue='amber', secondary_hue='gray', neutral_hue='amber')) as demo:\n",
116
+ " # gr.Markdown(\n",
117
+ " # \"\"\"\n",
118
+ " # Try our AI Product Recommendation DEMO!!!\n",
119
+ " # \"\"\"\n",
120
+ " # )\n",
121
+ " txt = gr.Textbox(value='A Christmas present🎄for my 5 years old Kid!!!', label='Try our AI Product Recommendation DEMO!!!')\n",
122
+ " btn = gr.Button(value=\"Search for Product\")\n",
123
  " state = gr.Dataframe()\n",
124
  " # btn.click(greet, inputs='text', outputs=['dataframe'])\n",
125
  " btn.click(greet, [txt], [state])\n",
app.py CHANGED
@@ -15,7 +15,7 @@ model = SentenceTransformer('all-mpnet-base-v2') #all-MiniLM-L6-v2 #all-mpnet-ba
15
  df = pd.read_parquet('df_encoded.parquet')
16
 
17
  #prepare model
18
- nbrs = NearestNeighbors(n_neighbors=5, algorithm='ball_tree').fit(df['text_vector_'].values.tolist())
19
 
20
  def search(df, query):
21
  product = model.encode(query).tolist()
@@ -34,8 +34,13 @@ def greet(text1):
34
  return search(df, text1)
35
 
36
  with gr.Blocks(theme=gr.themes.Soft(primary_hue='amber', secondary_hue='gray', neutral_hue='amber')) 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])
 
15
  df = pd.read_parquet('df_encoded.parquet')
16
 
17
  #prepare model
18
+ nbrs = NearestNeighbors(n_neighbors=4, algorithm='ball_tree').fit(df['text_vector_'].values.tolist())
19
 
20
  def search(df, query):
21
  product = model.encode(query).tolist()
 
34
  return search(df, text1)
35
 
36
  with gr.Blocks(theme=gr.themes.Soft(primary_hue='amber', secondary_hue='gray', neutral_hue='amber')) as demo:
37
+ gr.Markdown(
38
+ """
39
+ # Try our AI Product Recommendation DEMO!!!
40
+ """
41
+ )
42
  txt = gr.Textbox(value='A Christmas present🎄for my 5 years old Kid!!!', label='What are you looking for?')
43
+ btn = gr.Button(value="Search for Product")
44
  state = gr.Dataframe()
45
  # btn.click(greet, inputs='text', outputs=['dataframe'])
46
  btn.click(greet, [txt], [state])