Multiverse26 commited on
Commit
52b4a35
·
verified ·
1 Parent(s): 9c6712c
Files changed (1) hide show
  1. app.py +21 -7
app.py CHANGED
@@ -1,17 +1,31 @@
1
  import gradio as gr
2
- from transformers import pipeline
3
 
4
- generator = pipeline("text-generation", model="gpt2")
5
 
6
  def generate_caption(prompt):
7
- result = generator(prompt, max_length=50, num_return_sequences=3)
8
- return "\n\n".join([r['generated_text'] for r in result])
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  iface = gr.Interface(
11
  fn=generate_caption,
12
- inputs="text",
13
- outputs="text",
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()