Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ API_TOKEN = os.getenv("HF_READ_TOKEN")
|
|
15 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
16 |
timeout = 100
|
17 |
|
18 |
-
def query(prompt, is_negative=False
|
19 |
if prompt == "" or prompt == None:
|
20 |
return None
|
21 |
|
@@ -26,13 +26,7 @@ def query(prompt, is_negative=False, steps=15, cfg_scale=7, seed=-1, strength=0.
|
|
26 |
|
27 |
payload = {
|
28 |
"inputs": prompt,
|
29 |
-
"is_negative": is_negative
|
30 |
-
"steps": steps,
|
31 |
-
"cfg_scale": cfg_scale,
|
32 |
-
"seed": seed if seed != -1 else random.randint(1, 1000000000),
|
33 |
-
"strength": strength,
|
34 |
-
"width": 512,
|
35 |
-
"height": 1024
|
36 |
}
|
37 |
|
38 |
response = requests.post(API_URL, headers=headers, json=payload, timeout=timeout)
|
@@ -68,18 +62,14 @@ with gr.Blocks(theme='gstaff/xkcd', css=css) as app:
|
|
68 |
with gr.Row():
|
69 |
text_prompt = gr.Textbox(label="Prompt", placeholder="Enter a prompt here", lines=2, elem_id="prompt-text-input")
|
70 |
with gr.Row():
|
71 |
-
with gr.Accordion("Advanced Settings", open=
|
72 |
negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="What should not be in the image", value="(deformed, distorted, disfigured), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, misspellings, typos", lines=3, elem_id="negative-prompt-text-input")
|
73 |
-
steps = gr.Slider(label="Sampling steps", value=4, minimum=1, maximum=100, step=1)
|
74 |
-
cfg = gr.Slider(label="CFG Scale", value=7, minimum=1, maximum=20, step=1)
|
75 |
-
strength = gr.Slider(label="Strength", value=0.7, minimum=0, maximum=1, step=0.001)
|
76 |
-
seed = gr.Slider(label="Seed", value=-1, minimum=-1, maximum=1000000000, step=1)
|
77 |
|
78 |
with gr.Row():
|
79 |
text_button = gr.Button("Run", variant='primary', elem_id="gen-button")
|
80 |
with gr.Row():
|
81 |
image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
|
82 |
|
83 |
-
text_button.click(query, inputs=[text_prompt, negative_prompt
|
84 |
|
85 |
app.launch(show_api=True, share=True)
|
|
|
15 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
16 |
timeout = 100
|
17 |
|
18 |
+
def query(prompt, is_negative=False):
|
19 |
if prompt == "" or prompt == None:
|
20 |
return None
|
21 |
|
|
|
26 |
|
27 |
payload = {
|
28 |
"inputs": prompt,
|
29 |
+
"is_negative": is_negative
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
|
32 |
response = requests.post(API_URL, headers=headers, json=payload, timeout=timeout)
|
|
|
62 |
with gr.Row():
|
63 |
text_prompt = gr.Textbox(label="Prompt", placeholder="Enter a prompt here", lines=2, elem_id="prompt-text-input")
|
64 |
with gr.Row():
|
65 |
+
with gr.Accordion("Advanced Settings", open=True):
|
66 |
negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="What should not be in the image", value="(deformed, distorted, disfigured), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, misspellings, typos", lines=3, elem_id="negative-prompt-text-input")
|
|
|
|
|
|
|
|
|
67 |
|
68 |
with gr.Row():
|
69 |
text_button = gr.Button("Run", variant='primary', elem_id="gen-button")
|
70 |
with gr.Row():
|
71 |
image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
|
72 |
|
73 |
+
text_button.click(query, inputs=[text_prompt, negative_prompt], outputs=image_output)
|
74 |
|
75 |
app.launch(show_api=True, share=True)
|