Spaces:
aiqcamp
/
Running on Zero

aiqcamp commited on
Commit
2531620
·
verified ·
1 Parent(s): 4fde2f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +121 -61
app.py CHANGED
@@ -233,77 +233,137 @@ def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, num_in
233
  ).images[0]
234
  return image, seed
235
 
236
- # CSS 스타일
237
- css="""
238
- #col-container {
239
- margin: 0 auto;
240
- max-width: 520px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  }
242
  """
243
 
244
- # Gradio 인터페이스 생성
245
  with gr.Blocks(css=css) as demo:
246
- with gr.Column(elem_id="col-container"):
247
- gr.Markdown("""# FLUX.1 [schnell]
248
- 12B param rectified flow transformer distilled from [FLUX.1 [pro]](https://blackforestlabs.ai/) for 4 step generation
249
- [[blog](https://blackforestlabs.ai/announcing-black-forest-labs/)] [[model](https://huggingface.co/black-forest-labs/FLUX.1-schnell)]
250
  """)
251
-
252
- with gr.Row():
253
- prompt = gr.Text(
254
- label="Prompt",
255
- show_label=False,
256
- max_lines=1,
257
- placeholder="Enter your prompt",
258
- container=False,
259
- )
260
- run_button = gr.Button("Run", scale=0)
261
-
262
- result = gr.Image(label="Result", show_label=False)
263
-
264
- with gr.Accordion("Advanced Settings", open=False):
265
- seed = gr.Slider(
266
- label="Seed",
267
- minimum=0,
268
- maximum=MAX_SEED,
269
- step=1,
270
- value=0,
271
- )
272
-
273
- randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
274
 
275
- with gr.Row():
276
- width = gr.Slider(
277
- label="Width",
278
- minimum=256,
279
- maximum=MAX_IMAGE_SIZE,
280
- step=32,
281
- value=1024,
282
  )
 
283
 
284
- height = gr.Slider(
285
- label="Height",
286
- minimum=256,
287
- maximum=MAX_IMAGE_SIZE,
288
- step=32,
289
- value=1024,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  )
291
-
292
- num_inference_steps = gr.Slider(
293
- label="Number of inference steps",
294
- minimum=1,
295
- maximum=50,
296
- step=1,
297
- value=4,
298
- )
299
 
300
- gr.Examples(
301
- examples=GRADIO_EXAMPLES,
302
- fn=infer,
303
- inputs=[prompt],
304
- outputs=[result, seed],
305
- cache_examples="lazy"
306
- )
 
 
 
 
307
 
308
  gr.on(
309
  triggers=[run_button.click, prompt.submit],
 
233
  ).images[0]
234
  return image, seed
235
 
236
+ # CSS 스타일 수정
237
+ css = """
238
+ .container {
239
+ display: flex;
240
+ flex-direction: row;
241
+ height: 100%;
242
+ }
243
+
244
+ .input-column {
245
+ flex: 1;
246
+ padding: 20px;
247
+ border-right: 2px solid #eee;
248
+ max-width: 600px;
249
+ }
250
+
251
+ .examples-column {
252
+ flex: 1;
253
+ padding: 20px;
254
+ overflow-y: auto;
255
+ background: #f7f7f7;
256
+ }
257
+
258
+ .title {
259
+ text-align: center;
260
+ color: #2a2a2a;
261
+ padding: 20px;
262
+ font-size: 2.5em;
263
+ font-weight: bold;
264
+ background: linear-gradient(90deg, #f0f0f0 0%, #ffffff 100%);
265
+ border-bottom: 3px solid #ddd;
266
+ margin-bottom: 30px;
267
+ }
268
+
269
+ .subtitle {
270
+ text-align: center;
271
+ color: #666;
272
+ margin-bottom: 30px;
273
+ }
274
+
275
+ .input-box {
276
+ background: white;
277
+ padding: 20px;
278
+ border-radius: 10px;
279
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
280
+ margin-bottom: 20px;
281
+ }
282
+
283
+ .example-card {
284
+ background: white;
285
+ padding: 15px;
286
+ margin: 10px 0;
287
+ border-radius: 8px;
288
+ box-shadow: 0 2px 5px rgba(0,0,0,0.05);
289
+ }
290
+
291
+ .example-title {
292
+ font-weight: bold;
293
+ color: #2a2a2a;
294
+ margin-bottom: 10px;
295
  }
296
  """
297
 
298
+ # Gradio 인터페이스 수정
299
  with gr.Blocks(css=css) as demo:
300
+ gr.Markdown(
301
+ """
302
+ <div class="title">FLUX Diagram Generator</div>
303
+ <div class="subtitle">Create beautiful hand-drawn style diagrams using FLUX AI</div>
304
  """)
305
+
306
+ gr.HTML("""<a href="https://visitorbadge.io/status?path=https%3A%2F%2Faiqcamp-diagram.hf.space">
307
+ <img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Faiqcamp-diagram.hf.space&countColor=%23263759" />
308
+ </a>""")
309
+
310
+ with gr.Row(equal_height=True) as main_row:
311
+ # 왼쪽 입력 컬럼
312
+ with gr.Column(elem_id="input-column", scale=1):
313
+ with gr.Box(elem_classes="input-box"):
314
+ prompt = gr.Text(
315
+ label="Diagram Prompt",
316
+ placeholder="Enter your diagram structure...",
317
+ lines=5
318
+ )
319
+ run_button = gr.Button("Generate Diagram", variant="primary")
320
+ result = gr.Image(label="Generated Diagram")
 
 
 
 
 
 
 
321
 
322
+ with gr.Accordion("Advanced Settings", open=False):
323
+ seed = gr.Slider(
324
+ label="Seed",
325
+ minimum=0,
326
+ maximum=MAX_SEED,
327
+ step=1,
328
+ value=0,
329
  )
330
+ randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
331
 
332
+ with gr.Row():
333
+ width = gr.Slider(
334
+ label="Width",
335
+ minimum=256,
336
+ maximum=MAX_IMAGE_SIZE,
337
+ step=32,
338
+ value=1024,
339
+ )
340
+ height = gr.Slider(
341
+ label="Height",
342
+ minimum=256,
343
+ maximum=MAX_IMAGE_SIZE,
344
+ step=32,
345
+ value=1024,
346
+ )
347
+
348
+ num_inference_steps = gr.Slider(
349
+ label="Number of inference steps",
350
+ minimum=1,
351
+ maximum=50,
352
+ step=1,
353
+ value=4,
354
  )
 
 
 
 
 
 
 
 
355
 
356
+ # 오른쪽 예제 컬럼
357
+ with gr.Column(elem_id="examples-column", scale=1):
358
+ gr.Markdown("### Example Diagrams")
359
+ for example in EXAMPLES:
360
+ with gr.Box(elem_classes="example-card"):
361
+ gr.Markdown(f"#### {example['title']}")
362
+ gr.Markdown(f"```\n{example['prompt']}\n```")
363
+ if gr.Button("Use This Example", size="sm"):
364
+ prompt.update(value=example['prompt'])
365
+ width.update(value=example['width'])
366
+ height.update(value=example['height'])
367
 
368
  gr.on(
369
  triggers=[run_button.click, prompt.submit],