File size: 1,026 Bytes
fbf704f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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()