Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Load
|
5 |
-
query_parser = pipeline("text2text-generation", model="
|
6 |
|
7 |
def parse_query(user_query):
|
8 |
"""
|
@@ -10,19 +10,16 @@ def parse_query(user_query):
|
|
10 |
"""
|
11 |
output = query_parser(user_query, max_length=50, do_sample=False)
|
12 |
structured_response = output[0]['generated_text']
|
13 |
-
|
14 |
return structured_response
|
15 |
|
16 |
-
# Define
|
17 |
with gr.Blocks() as demo:
|
18 |
gr.Markdown("# 🛍️ Luxury Fashion Query Parser")
|
19 |
|
20 |
query_input = gr.Textbox(label="Enter your search query", placeholder="e.g., Gucci men’s perfume under 200AED")
|
21 |
-
|
22 |
output_box = gr.Textbox(label="Structured Output", placeholder="Brand: Gucci, Gender: Men, Category: Perfume, Price: 0-200 AED")
|
23 |
|
24 |
parse_button = gr.Button("Parse Query")
|
25 |
-
|
26 |
parse_button.click(parse_query, inputs=[query_input], outputs=[output_box])
|
27 |
|
28 |
# Launch the app
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load a compatible T5-based model for query parsing
|
5 |
+
query_parser = pipeline("text2text-generation", model="google/flan-t5-small")
|
6 |
|
7 |
def parse_query(user_query):
|
8 |
"""
|
|
|
10 |
"""
|
11 |
output = query_parser(user_query, max_length=50, do_sample=False)
|
12 |
structured_response = output[0]['generated_text']
|
|
|
13 |
return structured_response
|
14 |
|
15 |
+
# Define the Gradio UI
|
16 |
with gr.Blocks() as demo:
|
17 |
gr.Markdown("# 🛍️ Luxury Fashion Query Parser")
|
18 |
|
19 |
query_input = gr.Textbox(label="Enter your search query", placeholder="e.g., Gucci men’s perfume under 200AED")
|
|
|
20 |
output_box = gr.Textbox(label="Structured Output", placeholder="Brand: Gucci, Gender: Men, Category: Perfume, Price: 0-200 AED")
|
21 |
|
22 |
parse_button = gr.Button("Parse Query")
|
|
|
23 |
parse_button.click(parse_query, inputs=[query_input], outputs=[output_box])
|
24 |
|
25 |
# Launch the app
|