Spaces:
Runtime error
Runtime error
Provide safe prompts for diversity
Browse files
app.py
CHANGED
|
@@ -8,6 +8,34 @@ from gradio_client import Client
|
|
| 8 |
import torch
|
| 9 |
from transformers import pipeline
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
pipe_safety = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta", torch_dtype=torch.bfloat16, device_map="auto")
|
| 12 |
|
| 13 |
agent_maker_sys = os.environ.get("SAFETY_PROMPT")
|
|
@@ -142,10 +170,12 @@ with gr.Blocks(css=css) as app:
|
|
| 142 |
with gr.Row():
|
| 143 |
with gr.Column(scale=2):
|
| 144 |
if is_shared_ui:
|
| 145 |
-
prompt = gr.
|
| 146 |
label="Prompt", info='''Duplicate the space to you personal account for custom prompt''',
|
|
|
|
| 147 |
value="a person, darkblue suit, black tie, white pocket",
|
| 148 |
-
interactive=
|
|
|
|
| 149 |
)
|
| 150 |
else:
|
| 151 |
prompt = gr.Textbox(
|
|
|
|
| 8 |
import torch
|
| 9 |
from transformers import pipeline
|
| 10 |
|
| 11 |
+
safe_prompts = [
|
| 12 |
+
"a person, dark blue suit, black tie, white pocket",
|
| 13 |
+
"a person, light gray suit, navy tie, white shirt",
|
| 14 |
+
"a person, beige blazer, white turtleneck, brown slacks",
|
| 15 |
+
"a person, dark green jacket, patterned scarf, black trousers",
|
| 16 |
+
"a person, formal black suit, red tie, white shirt",
|
| 17 |
+
"a person, navy blazer, light blue shirt, no tie",
|
| 18 |
+
"a person, charcoal suit, silver tie, matching vest",
|
| 19 |
+
"a person, tan trench coat, plaid scarf, gloves",
|
| 20 |
+
"a person, white shirt, navy vest, black pants",
|
| 21 |
+
"a person, casual sweater, collared shirt, khaki pants",
|
| 22 |
+
"a person, elegant tuxedo, bow tie, white gloves",
|
| 23 |
+
"a person, dark brown suit, olive tie, pocket square",
|
| 24 |
+
"a person, white t-shirt, denim jacket, black jeans",
|
| 25 |
+
"a person, long red coat, black scarf, winter boots",
|
| 26 |
+
"a person, floral summer dress, sun hat, sandals",
|
| 27 |
+
"a person, athletic hoodie, running pants, sneakers",
|
| 28 |
+
"a person, yellow raincoat, rubber boots, umbrella",
|
| 29 |
+
"a person, black leather jacket, white t-shirt, dark jeans",
|
| 30 |
+
"a person, pastel sweater, pleated skirt, ankle boots",
|
| 31 |
+
"a person, traditional kimono, obi belt, white socks",
|
| 32 |
+
"a person, business dress, black heels, pearl necklace",
|
| 33 |
+
"a person, beige cardigan, striped shirt, blue jeans",
|
| 34 |
+
"a person, safari jacket, khaki shorts, hiking boots",
|
| 35 |
+
"a person, black sweater, long coat, gray trousers"
|
| 36 |
+
]
|
| 37 |
+
|
| 38 |
+
|
| 39 |
pipe_safety = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta", torch_dtype=torch.bfloat16, device_map="auto")
|
| 40 |
|
| 41 |
agent_maker_sys = os.environ.get("SAFETY_PROMPT")
|
|
|
|
| 170 |
with gr.Row():
|
| 171 |
with gr.Column(scale=2):
|
| 172 |
if is_shared_ui:
|
| 173 |
+
prompt = gr.Dropdown(
|
| 174 |
label="Prompt", info='''Duplicate the space to you personal account for custom prompt''',
|
| 175 |
+
choices=safe_prompts,
|
| 176 |
value="a person, darkblue suit, black tie, white pocket",
|
| 177 |
+
interactive=True,
|
| 178 |
+
allow_custom_value=False
|
| 179 |
)
|
| 180 |
else:
|
| 181 |
prompt = gr.Textbox(
|