Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load model (You can replace this with any model like GPT-2 or your custom one)
|
5 |
+
generator = pipeline("text-generation", model="gpt2")
|
6 |
+
|
7 |
+
def generate_description(title, tags):
|
8 |
+
prompt = f"Generate an SEO-friendly product description for a product titled '{title}' with tags: {tags}."
|
9 |
+
result = generator(prompt, max_length=100, num_return_sequences=1)
|
10 |
+
return result[0]['generated_text']
|
11 |
+
|
12 |
+
# Gradio UI
|
13 |
+
interface = gr.Interface(
|
14 |
+
fn=generate_description,
|
15 |
+
inputs=[
|
16 |
+
gr.Textbox(label="Product Title"),
|
17 |
+
gr.Textbox(label="Tags (comma-separated)")
|
18 |
+
],
|
19 |
+
outputs=gr.Textbox(label="Generated Description"),
|
20 |
+
title="E-Commerce Product Description Generator",
|
21 |
+
description="Enter product title and tags to generate an SEO-optimized product description."
|
22 |
+
)
|
23 |
+
|
24 |
+
interface.launch()
|