Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,20 +2,20 @@ import gradio as gr
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
client = InferenceClient(
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def generate_caption(prompt):
|
| 8 |
prompt = f"Write 3 short luxury Instagram captions for: {prompt}. Keep them elegant and minimal."
|
| 9 |
|
| 10 |
-
response = client.
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
{"role": "user", "content": prompt}
|
| 14 |
-
],
|
| 15 |
-
max_tokens=120
|
| 16 |
)
|
| 17 |
|
| 18 |
-
return response.
|
| 19 |
|
| 20 |
iface = gr.Interface(
|
| 21 |
fn=generate_caption,
|
|
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
client = InferenceClient(
|
| 6 |
+
model="google/flan-t5-small",
|
| 7 |
+
token=os.getenv("HF_TOKEN")
|
| 8 |
+
)
|
| 9 |
|
| 10 |
def generate_caption(prompt):
|
| 11 |
prompt = f"Write 3 short luxury Instagram captions for: {prompt}. Keep them elegant and minimal."
|
| 12 |
|
| 13 |
+
response = client.text_generation(
|
| 14 |
+
prompt,
|
| 15 |
+
max_new_tokens=80
|
|
|
|
|
|
|
|
|
|
| 16 |
)
|
| 17 |
|
| 18 |
+
return response.strip()
|
| 19 |
|
| 20 |
iface = gr.Interface(
|
| 21 |
fn=generate_caption,
|