File size: 991 Bytes
2270fc8
 
 
 
769e011
2270fc8
 
769e011
2270fc8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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()