|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
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'] |
|
|
|
|
|
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() |
|
|