Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -58,96 +58,30 @@ examples = [
|
|
| 58 |
]
|
| 59 |
|
| 60 |
css = """
|
| 61 |
-
:root {
|
| 62 |
-
--primary: #6e6af0;
|
| 63 |
-
--secondary: #f5f5f7;
|
| 64 |
-
--accent: #f5f5f7;
|
| 65 |
-
--text: #1e1e1e;
|
| 66 |
-
--shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
| 67 |
-
}
|
| 68 |
-
|
| 69 |
#col-container {
|
| 70 |
margin: 0 auto;
|
| 71 |
-
max-width:
|
| 72 |
-
padding: 20px;
|
| 73 |
-
}
|
| 74 |
-
|
| 75 |
-
.header {
|
| 76 |
-
text-align: center;
|
| 77 |
-
margin-bottom: 20px;
|
| 78 |
-
}
|
| 79 |
-
|
| 80 |
-
.header h1 {
|
| 81 |
-
font-size: 2.5rem;
|
| 82 |
-
font-weight: 700;
|
| 83 |
-
color: var(--primary);
|
| 84 |
-
margin-bottom: 10px;
|
| 85 |
-
}
|
| 86 |
-
|
| 87 |
-
.prompt-container {
|
| 88 |
-
background: white;
|
| 89 |
-
border-radius: 12px;
|
| 90 |
-
padding: 20px;
|
| 91 |
-
box-shadow: var(--shadow);
|
| 92 |
-
margin-bottom: 20px;
|
| 93 |
-
}
|
| 94 |
-
|
| 95 |
-
.result-container {
|
| 96 |
-
background: white;
|
| 97 |
-
border-radius: 12px;
|
| 98 |
-
padding: 20px;
|
| 99 |
-
box-shadow: var(--shadow);
|
| 100 |
-
margin-bottom: 20px;
|
| 101 |
-
}
|
| 102 |
-
|
| 103 |
-
.advanced-settings {
|
| 104 |
-
background: white;
|
| 105 |
-
border-radius: 12px;
|
| 106 |
-
padding: 20px;
|
| 107 |
-
box-shadow: var(--shadow);
|
| 108 |
-
}
|
| 109 |
-
|
| 110 |
-
.btn-primary {
|
| 111 |
-
background: var(--primary) !important;
|
| 112 |
-
border: none !important;
|
| 113 |
-
}
|
| 114 |
-
|
| 115 |
-
.btn-primary:hover {
|
| 116 |
-
opacity: 0.9 !important;
|
| 117 |
-
}
|
| 118 |
-
|
| 119 |
-
.examples {
|
| 120 |
-
margin-top: 20px;
|
| 121 |
}
|
| 122 |
"""
|
| 123 |
|
| 124 |
with gr.Blocks(css=css) as demo:
|
| 125 |
with gr.Column(elem_id="col-container"):
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
|
|
|
| 134 |
)
|
| 135 |
|
| 136 |
-
|
| 137 |
-
with gr.Row():
|
| 138 |
-
prompt = gr.Text(
|
| 139 |
-
label="Prompt",
|
| 140 |
-
show_label=False,
|
| 141 |
-
max_lines=1,
|
| 142 |
-
placeholder="Enter your prompt",
|
| 143 |
-
container=False,
|
| 144 |
-
)
|
| 145 |
-
run_button = gr.Button("Run", scale=0, variant="primary", elem_classes="btn-primary")
|
| 146 |
|
| 147 |
-
|
| 148 |
-
result = gr.Image(label="Result", show_label=False)
|
| 149 |
|
| 150 |
-
with gr.Accordion("Advanced Settings", open=False
|
| 151 |
negative_prompt = gr.Text(
|
| 152 |
label="Negative prompt",
|
| 153 |
max_lines=1,
|
|
@@ -171,7 +105,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 171 |
minimum=256,
|
| 172 |
maximum=MAX_IMAGE_SIZE,
|
| 173 |
step=32,
|
| 174 |
-
value=1024,
|
| 175 |
)
|
| 176 |
|
| 177 |
height = gr.Slider(
|
|
@@ -179,7 +113,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 179 |
minimum=256,
|
| 180 |
maximum=MAX_IMAGE_SIZE,
|
| 181 |
step=32,
|
| 182 |
-
value=1024,
|
| 183 |
)
|
| 184 |
|
| 185 |
with gr.Row():
|
|
@@ -188,7 +122,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 188 |
minimum=0.0,
|
| 189 |
maximum=10.0,
|
| 190 |
step=0.1,
|
| 191 |
-
value=0.0,
|
| 192 |
)
|
| 193 |
|
| 194 |
num_inference_steps = gr.Slider(
|
|
@@ -196,11 +130,10 @@ with gr.Blocks(css=css) as demo:
|
|
| 196 |
minimum=1,
|
| 197 |
maximum=50,
|
| 198 |
step=1,
|
| 199 |
-
value=2,
|
| 200 |
)
|
| 201 |
|
| 202 |
-
gr.Examples(examples=examples, inputs=[prompt]
|
| 203 |
-
|
| 204 |
gr.on(
|
| 205 |
triggers=[run_button.click, prompt.submit],
|
| 206 |
fn=infer,
|
|
|
|
| 58 |
]
|
| 59 |
|
| 60 |
css = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
#col-container {
|
| 62 |
margin: 0 auto;
|
| 63 |
+
max-width: 640px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
}
|
| 65 |
"""
|
| 66 |
|
| 67 |
with gr.Blocks(css=css) as demo:
|
| 68 |
with gr.Column(elem_id="col-container"):
|
| 69 |
+
gr.Markdown(" # Text-to-Image Gradio Template")
|
| 70 |
+
|
| 71 |
+
with gr.Row():
|
| 72 |
+
prompt = gr.Text(
|
| 73 |
+
label="Prompt",
|
| 74 |
+
show_label=False,
|
| 75 |
+
max_lines=1,
|
| 76 |
+
placeholder="Enter your prompt",
|
| 77 |
+
container=False,
|
| 78 |
)
|
| 79 |
|
| 80 |
+
run_button = gr.Button("Run", scale=0, variant="primary")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
+
result = gr.Image(label="Result", show_label=False)
|
|
|
|
| 83 |
|
| 84 |
+
with gr.Accordion("Advanced Settings", open=False):
|
| 85 |
negative_prompt = gr.Text(
|
| 86 |
label="Negative prompt",
|
| 87 |
max_lines=1,
|
|
|
|
| 105 |
minimum=256,
|
| 106 |
maximum=MAX_IMAGE_SIZE,
|
| 107 |
step=32,
|
| 108 |
+
value=1024, # Replace with defaults that work for your model
|
| 109 |
)
|
| 110 |
|
| 111 |
height = gr.Slider(
|
|
|
|
| 113 |
minimum=256,
|
| 114 |
maximum=MAX_IMAGE_SIZE,
|
| 115 |
step=32,
|
| 116 |
+
value=1024, # Replace with defaults that work for your model
|
| 117 |
)
|
| 118 |
|
| 119 |
with gr.Row():
|
|
|
|
| 122 |
minimum=0.0,
|
| 123 |
maximum=10.0,
|
| 124 |
step=0.1,
|
| 125 |
+
value=0.0, # Replace with defaults that work for your model
|
| 126 |
)
|
| 127 |
|
| 128 |
num_inference_steps = gr.Slider(
|
|
|
|
| 130 |
minimum=1,
|
| 131 |
maximum=50,
|
| 132 |
step=1,
|
| 133 |
+
value=2, # Replace with defaults that work for your model
|
| 134 |
)
|
| 135 |
|
| 136 |
+
gr.Examples(examples=examples, inputs=[prompt])
|
|
|
|
| 137 |
gr.on(
|
| 138 |
triggers=[run_button.click, prompt.submit],
|
| 139 |
fn=infer,
|