Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,18 +38,18 @@ def generate_improved_prompt(logo_request, temperature=0.9, max_new_tokens=512,
|
|
| 38 |
|
| 39 |
for response in stream:
|
| 40 |
output += response.token.text
|
| 41 |
-
|
| 42 |
|
| 43 |
-
def generate_image(prompt):
|
| 44 |
result = client_playground.predict(
|
| 45 |
prompt,
|
| 46 |
"", # negative prompt
|
| 47 |
False, # use negative prompt
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
api_name="/run"
|
| 54 |
)
|
| 55 |
|
|
@@ -74,24 +74,28 @@ css = """
|
|
| 74 |
}
|
| 75 |
"""
|
| 76 |
|
| 77 |
-
def process_request(logo_request):
|
| 78 |
-
improved_prompt =
|
| 79 |
-
image = generate_image(improved_prompt)
|
| 80 |
-
return image
|
| 81 |
|
| 82 |
with gr.Blocks(css=css) as app:
|
| 83 |
with gr.Row():
|
| 84 |
with gr.Column(scale=2):
|
| 85 |
gr.HTML("<h1>Settings</h1>")
|
| 86 |
logo_input = gr.Textbox(label="Input your logo request", placeholder="Describe the logo you want...")
|
|
|
|
|
|
|
|
|
|
| 87 |
with gr.Column(scale=3):
|
| 88 |
-
gr.HTML("<h1><center>
|
| 89 |
generate_button = gr.Button("Generate")
|
| 90 |
-
|
|
|
|
| 91 |
generate_button.click(
|
| 92 |
fn=process_request,
|
| 93 |
-
inputs=[logo_input],
|
| 94 |
-
outputs=
|
| 95 |
)
|
| 96 |
|
| 97 |
gr.Markdown("""
|
|
|
|
| 38 |
|
| 39 |
for response in stream:
|
| 40 |
output += response.token.text
|
| 41 |
+
return output
|
| 42 |
|
| 43 |
+
def generate_image(prompt, width=1024, height=1024, guidance_scale=7.5):
|
| 44 |
result = client_playground.predict(
|
| 45 |
prompt,
|
| 46 |
"", # negative prompt
|
| 47 |
False, # use negative prompt
|
| 48 |
+
0, # seed
|
| 49 |
+
width, # width
|
| 50 |
+
height, # height
|
| 51 |
+
guidance_scale, # guidance scale
|
| 52 |
+
True, # randomize seed
|
| 53 |
api_name="/run"
|
| 54 |
)
|
| 55 |
|
|
|
|
| 74 |
}
|
| 75 |
"""
|
| 76 |
|
| 77 |
+
def process_request(logo_request, width, height, guidance_scale):
|
| 78 |
+
improved_prompt = generate_improved_prompt(logo_request)
|
| 79 |
+
image = generate_image(improved_prompt, width, height, guidance_scale)
|
| 80 |
+
return improved_prompt, image
|
| 81 |
|
| 82 |
with gr.Blocks(css=css) as app:
|
| 83 |
with gr.Row():
|
| 84 |
with gr.Column(scale=2):
|
| 85 |
gr.HTML("<h1>Settings</h1>")
|
| 86 |
logo_input = gr.Textbox(label="Input your logo request", placeholder="Describe the logo you want...")
|
| 87 |
+
width = gr.Slider(label="Width", minimum=256, maximum=1536, value=1024)
|
| 88 |
+
height = gr.Slider(label="Height", minimum=256, maximum=1536, value=1024)
|
| 89 |
+
guidance_scale = gr.Slider(label="Guidance Scale", minimum=0.1, maximum=20, value=7.5)
|
| 90 |
with gr.Column(scale=3):
|
| 91 |
+
gr.HTML("<h1><center>Logo Prompt Generator<h1><center>")
|
| 92 |
generate_button = gr.Button("Generate")
|
| 93 |
+
prompt_output = gr.Textbox(label="Generated Prompt", interactive=False, lines=5)
|
| 94 |
+
image_output = gr.Image(label="Generated Image")
|
| 95 |
generate_button.click(
|
| 96 |
fn=process_request,
|
| 97 |
+
inputs=[logo_input, width, height, guidance_scale],
|
| 98 |
+
outputs=[prompt_output, image_output]
|
| 99 |
)
|
| 100 |
|
| 101 |
gr.Markdown("""
|