Spaces:
Sleeping
Sleeping
app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,31 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
|
| 4 |
-
|
| 5 |
|
| 6 |
def generate_caption(prompt):
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
iface = gr.Interface(
|
| 11 |
fn=generate_caption,
|
| 12 |
-
inputs="
|
| 13 |
-
outputs="
|
| 14 |
-
title="AI Caption Generator"
|
|
|
|
| 15 |
)
|
| 16 |
|
| 17 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
+
client = InferenceClient(model="HuggingFaceH4/zephyr-7b-beta")
|
| 5 |
|
| 6 |
def generate_caption(prompt):
|
| 7 |
+
prompt = f"""
|
| 8 |
+
Write 3 short, aesthetic Instagram captions for a luxury jewelry product.
|
| 9 |
+
|
| 10 |
+
Product: {prompt}
|
| 11 |
+
|
| 12 |
+
Style:
|
| 13 |
+
- Elegant
|
| 14 |
+
- Minimal
|
| 15 |
+
- Premium tone
|
| 16 |
+
- No long paragraphs
|
| 17 |
+
|
| 18 |
+
Output:
|
| 19 |
+
"""
|
| 20 |
+
response = client.text_generation(prompt, max_new_tokens=120)
|
| 21 |
+
return response
|
| 22 |
|
| 23 |
iface = gr.Interface(
|
| 24 |
fn=generate_caption,
|
| 25 |
+
inputs=gr.Textbox(placeholder="Enter product (e.g. gold earrings)"),
|
| 26 |
+
outputs=gr.Textbox(label="Captions"),
|
| 27 |
+
title="✨ AI Luxury Caption Generator",
|
| 28 |
+
description="Generate premium captions for your brand"
|
| 29 |
)
|
| 30 |
|
| 31 |
iface.launch()
|