Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -162,11 +162,59 @@ def generate_image(prompt,
|
|
| 162 |
return [Image.fromarray(images[i]).resize((768, 768), Image.LANCZOS) for i in range(parallel_size)]
|
| 163 |
|
| 164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
# Gradio interface with improved UI
|
| 166 |
-
with gr.Blocks(
|
| 167 |
-
primary_hue="blue",
|
| 168 |
-
|
| 169 |
-
)
|
| 170 |
gr.Markdown(
|
| 171 |
"""
|
| 172 |
# Deepseek Multimodal
|
|
@@ -181,7 +229,7 @@ with gr.Blocks(theme=gr.themes.Soft(
|
|
| 181 |
|
| 182 |
with gr.Tabs():
|
| 183 |
# Visual Chat Tab
|
| 184 |
-
with gr.Tab("Visual Understanding"):
|
| 185 |
with gr.Row(equal_height=True):
|
| 186 |
with gr.Column(scale=1):
|
| 187 |
image_input = gr.Image(
|
|
@@ -222,8 +270,7 @@ with gr.Blocks(theme=gr.themes.Soft(
|
|
| 222 |
|
| 223 |
understanding_button = gr.Button(
|
| 224 |
"Analyze Image",
|
| 225 |
-
variant="primary"
|
| 226 |
-
size="lg"
|
| 227 |
)
|
| 228 |
|
| 229 |
understanding_output = gr.Textbox(
|
|
@@ -244,7 +291,7 @@ with gr.Blocks(theme=gr.themes.Soft(
|
|
| 244 |
)
|
| 245 |
|
| 246 |
# Image Generation Tab
|
| 247 |
-
with gr.Tab("Image Generation"):
|
| 248 |
with gr.Column():
|
| 249 |
prompt_input = gr.Textbox(
|
| 250 |
label="Image Description",
|
|
@@ -278,8 +325,7 @@ with gr.Blocks(theme=gr.themes.Soft(
|
|
| 278 |
|
| 279 |
generation_button = gr.Button(
|
| 280 |
"Generate Images",
|
| 281 |
-
variant="primary"
|
| 282 |
-
size="lg"
|
| 283 |
)
|
| 284 |
|
| 285 |
image_output = gr.Gallery(
|
|
@@ -315,54 +361,6 @@ with gr.Blocks(theme=gr.themes.Soft(
|
|
| 315 |
outputs=image_output
|
| 316 |
)
|
| 317 |
|
| 318 |
-
# Add custom CSS
|
| 319 |
-
demo.load(css="""
|
| 320 |
-
.gradio-container {
|
| 321 |
-
font-family: 'Inter', -apple-system, sans-serif;
|
| 322 |
-
}
|
| 323 |
-
.image-preview {
|
| 324 |
-
min-height: 300px;
|
| 325 |
-
max-height: 500px;
|
| 326 |
-
width: 100%;
|
| 327 |
-
object-fit: contain;
|
| 328 |
-
border-radius: 8px;
|
| 329 |
-
border: 2px solid #eee;
|
| 330 |
-
}
|
| 331 |
-
.tab-nav {
|
| 332 |
-
background: white;
|
| 333 |
-
padding: 1rem;
|
| 334 |
-
border-radius: 8px;
|
| 335 |
-
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
| 336 |
-
}
|
| 337 |
-
.examples-table {
|
| 338 |
-
font-size: 0.9rem;
|
| 339 |
-
}
|
| 340 |
-
.gr-button.gr-button-lg {
|
| 341 |
-
padding: 12px 24px;
|
| 342 |
-
font-size: 1.1rem;
|
| 343 |
-
}
|
| 344 |
-
.gr-input, .gr-select {
|
| 345 |
-
border-radius: 6px;
|
| 346 |
-
}
|
| 347 |
-
.gr-form {
|
| 348 |
-
background: white;
|
| 349 |
-
padding: 20px;
|
| 350 |
-
border-radius: 12px;
|
| 351 |
-
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
|
| 352 |
-
}
|
| 353 |
-
.gr-panel {
|
| 354 |
-
border: none;
|
| 355 |
-
background: transparent;
|
| 356 |
-
}
|
| 357 |
-
.footer {
|
| 358 |
-
text-align: center;
|
| 359 |
-
margin-top: 2rem;
|
| 360 |
-
padding: 1rem;
|
| 361 |
-
color: #666;
|
| 362 |
-
}
|
| 363 |
-
""")
|
| 364 |
-
|
| 365 |
# Launch the demo
|
| 366 |
if __name__ == "__main__":
|
| 367 |
demo.launch(share=True)
|
| 368 |
-
|
|
|
|
| 162 |
return [Image.fromarray(images[i]).resize((768, 768), Image.LANCZOS) for i in range(parallel_size)]
|
| 163 |
|
| 164 |
|
| 165 |
+
|
| 166 |
+
# Custom CSS as a string
|
| 167 |
+
custom_css = """
|
| 168 |
+
.gradio-container {
|
| 169 |
+
font-family: 'Inter', -apple-system, sans-serif;
|
| 170 |
+
}
|
| 171 |
+
.image-preview {
|
| 172 |
+
min-height: 300px;
|
| 173 |
+
max-height: 500px;
|
| 174 |
+
width: 100%;
|
| 175 |
+
object-fit: contain;
|
| 176 |
+
border-radius: 8px;
|
| 177 |
+
border: 2px solid #eee;
|
| 178 |
+
}
|
| 179 |
+
.tab-nav {
|
| 180 |
+
background: white;
|
| 181 |
+
padding: 1rem;
|
| 182 |
+
border-radius: 8px;
|
| 183 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
| 184 |
+
}
|
| 185 |
+
.examples-table {
|
| 186 |
+
font-size: 0.9rem;
|
| 187 |
+
}
|
| 188 |
+
.gr-button.gr-button-lg {
|
| 189 |
+
padding: 12px 24px;
|
| 190 |
+
font-size: 1.1rem;
|
| 191 |
+
}
|
| 192 |
+
.gr-input, .gr-select {
|
| 193 |
+
border-radius: 6px;
|
| 194 |
+
}
|
| 195 |
+
.gr-form {
|
| 196 |
+
background: white;
|
| 197 |
+
padding: 20px;
|
| 198 |
+
border-radius: 12px;
|
| 199 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
|
| 200 |
+
}
|
| 201 |
+
.gr-panel {
|
| 202 |
+
border: none;
|
| 203 |
+
background: transparent;
|
| 204 |
+
}
|
| 205 |
+
.footer {
|
| 206 |
+
text-align: center;
|
| 207 |
+
margin-top: 2rem;
|
| 208 |
+
padding: 1rem;
|
| 209 |
+
color: #666;
|
| 210 |
+
}
|
| 211 |
+
"""
|
| 212 |
+
|
| 213 |
# Gradio interface with improved UI
|
| 214 |
+
with gr.Blocks(
|
| 215 |
+
theme=gr.themes.Soft(primary_hue="blue", secondary_hue="indigo"),
|
| 216 |
+
css=custom_css
|
| 217 |
+
) as demo:
|
| 218 |
gr.Markdown(
|
| 219 |
"""
|
| 220 |
# Deepseek Multimodal
|
|
|
|
| 229 |
|
| 230 |
with gr.Tabs():
|
| 231 |
# Visual Chat Tab
|
| 232 |
+
with gr.Tab("Visual Understanding"):
|
| 233 |
with gr.Row(equal_height=True):
|
| 234 |
with gr.Column(scale=1):
|
| 235 |
image_input = gr.Image(
|
|
|
|
| 270 |
|
| 271 |
understanding_button = gr.Button(
|
| 272 |
"Analyze Image",
|
| 273 |
+
variant="primary"
|
|
|
|
| 274 |
)
|
| 275 |
|
| 276 |
understanding_output = gr.Textbox(
|
|
|
|
| 291 |
)
|
| 292 |
|
| 293 |
# Image Generation Tab
|
| 294 |
+
with gr.Tab("Image Generation"):
|
| 295 |
with gr.Column():
|
| 296 |
prompt_input = gr.Textbox(
|
| 297 |
label="Image Description",
|
|
|
|
| 325 |
|
| 326 |
generation_button = gr.Button(
|
| 327 |
"Generate Images",
|
| 328 |
+
variant="primary"
|
|
|
|
| 329 |
)
|
| 330 |
|
| 331 |
image_output = gr.Gallery(
|
|
|
|
| 361 |
outputs=image_output
|
| 362 |
)
|
| 363 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 364 |
# Launch the demo
|
| 365 |
if __name__ == "__main__":
|
| 366 |
demo.launch(share=True)
|
|
|