Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load fine-tuned model from Hugging Face Hub
|
| 5 |
+
t5_recommender = pipeline(model="RedaAlami/t5_recommendation_sports_equipment_english")
|
| 6 |
+
|
| 7 |
+
def recommend(items_purchased, candidates):
|
| 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']
|
| 11 |
+
return recommendation
|
| 12 |
+
|
| 13 |
+
with gr.Blocks() as demo:
|
| 14 |
+
gr.Markdown("# Sports Equipment Recommender")
|
| 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=[items_input, candidates_input], outputs=recommendation_output)
|
| 24 |
+
|
| 25 |
+
demo.launch()
|