Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,17 @@ from transformers import pipeline
|
|
| 4 |
# Load fine-tuned model from Hugging Face Hub
|
| 5 |
t5_recommender = pipeline(model="RedaAlami/t5_recommendation_sports_equipment_english")
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
prompt = f"ITEMS PURCHASED: {{{items_purchased}}} - CANDIDATES FOR RECOMMENDATION: {{{candidates}}} - RECOMMENDATION: "
|
| 9 |
model_output = t5_recommender(prompt)
|
| 10 |
recommendation = model_output[0]['generated_text']
|
|
@@ -15,11 +25,10 @@ with gr.Blocks() as demo:
|
|
| 15 |
with gr.Row():
|
| 16 |
with gr.Column():
|
| 17 |
items_input = gr.Textbox(label="Items Purchased")
|
| 18 |
-
candidates_input = gr.Textbox(label="Candidates for Recommendation")
|
| 19 |
with gr.Column():
|
| 20 |
recommendation_output = gr.Textbox(label="Recommendation")
|
| 21 |
|
| 22 |
recommend_button = gr.Button("Get Recommendation")
|
| 23 |
-
recommend_button.click(fn=recommend, inputs=
|
| 24 |
|
| 25 |
demo.launch()
|
|
|
|
| 4 |
# Load fine-tuned model from Hugging Face Hub
|
| 5 |
t5_recommender = pipeline(model="RedaAlami/t5_recommendation_sports_equipment_english")
|
| 6 |
|
| 7 |
+
# Fixed list of candidates
|
| 8 |
+
candidates = (
|
| 9 |
+
"Soccer Jersey, Basketball Jersey, Football Jersey, Baseball Jersey, Tennis Shirt, "
|
| 10 |
+
"Hockey Jersey, Soccer Ball, Basketball, Football, Baseball, Tennis Ball, Hocket Puck, "
|
| 11 |
+
"Soccer Cleats, Basketball Shoes, Football Cleats, Baseball Cleats, Tennis Shoes, Hockey Helmet, "
|
| 12 |
+
"Goalie Gloves, Basketball Arm Sleeve, Football Shoulder Pads, Baseball Cap, Tennis Racket, Hockey Skates, "
|
| 13 |
+
"Soccer Goal Post, Basketball Hoop, Football Helmet, Baseball Bat, Hockey Stick, Soccer Cones, Basketball Shorts, "
|
| 14 |
+
"Baseball Glove, Hockey Pads, Soccer Shorts"
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
def recommend(items_purchased):
|
| 18 |
prompt = f"ITEMS PURCHASED: {{{items_purchased}}} - CANDIDATES FOR RECOMMENDATION: {{{candidates}}} - RECOMMENDATION: "
|
| 19 |
model_output = t5_recommender(prompt)
|
| 20 |
recommendation = model_output[0]['generated_text']
|
|
|
|
| 25 |
with gr.Row():
|
| 26 |
with gr.Column():
|
| 27 |
items_input = gr.Textbox(label="Items Purchased")
|
|
|
|
| 28 |
with gr.Column():
|
| 29 |
recommendation_output = gr.Textbox(label="Recommendation")
|
| 30 |
|
| 31 |
recommend_button = gr.Button("Get Recommendation")
|
| 32 |
+
recommend_button.click(fn=recommend, inputs=items_input, outputs=recommendation_output)
|
| 33 |
|
| 34 |
demo.launch()
|