akruti24's picture
Update app.py
769e011 verified
raw
history blame contribute delete
991 Bytes
import gradio as gr
from transformers import pipeline
# Load model (You can replace this with any model like GPT-2 or your custom one)
generator = pipeline("text-generation", model="gpt2")
def generate_description(title, tags):
prompt = f"Write a clear, professional, and SEO-optimized product description for an e-commerce listing. The product title is: '{title}'. The relevant tags or features include: {tags}. Mention key benefits, usage, and appeal to buyers."
result = generator(prompt, max_length=100, num_return_sequences=1)
return result[0]['generated_text']
# Gradio UI
interface = gr.Interface(
fn=generate_description,
inputs=[
gr.Textbox(label="Product Title"),
gr.Textbox(label="Tags (comma-separated)")
],
outputs=gr.Textbox(label="Generated Description"),
title="E-Commerce Product Description Generator",
description="Enter product title and tags to generate an SEO-optimized product description."
)
interface.launch()