RedaAlami's picture
Create app.py
fbf704f verified
raw
history blame
1.03 kB
import gradio as gr
from transformers import pipeline
# Load fine-tuned model from Hugging Face Hub
t5_recommender = pipeline(model="RedaAlami/t5_recommendation_sports_equipment_english")
def recommend(items_purchased, candidates):
prompt = f"ITEMS PURCHASED: {{{items_purchased}}} - CANDIDATES FOR RECOMMENDATION: {{{candidates}}} - RECOMMENDATION: "
model_output = t5_recommender(prompt)
recommendation = model_output[0]['generated_text']
return recommendation
with gr.Blocks() as demo:
gr.Markdown("# Sports Equipment Recommender")
with gr.Row():
with gr.Column():
items_input = gr.Textbox(label="Items Purchased")
candidates_input = gr.Textbox(label="Candidates for Recommendation")
with gr.Column():
recommendation_output = gr.Textbox(label="Recommendation")
recommend_button = gr.Button("Get Recommendation")
recommend_button.click(fn=recommend, inputs=[items_input, candidates_input], outputs=recommendation_output)
demo.launch()