Spaces:
Paused
Paused
Update app.py
Browse files10 unmodified lines111213141415161718192011 unmodified lines3233343536353738394041424344454647484939404142434445464748495050515253545556575859606162636410 unmodified linespipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=dtype).to(device)
MAX_SEED = np.iinfo(np.int32).maxWIDTH = 900WIDTH = 700HEIGHT = 900
@spaces.GPU()def infer(prompt, progress=gr.Progress(track_tqdm=True)): seed = random.randint(0, MAX_SEED)11 unmodified lines image.save(out_path) return image, gr.update(value=out_path, visible=True)
css = """#col-container { margin: 0 auto; max-width: 900px; } @media (max-width: 600px) { #result-container { width: 100% !important; max-width: 100% !important; height: 70vh !important; max-height: 70vh !important; display: flex !important; align-items: center !important; justify-content: center !important; } #result-container img { width: auto !important; height: auto !important; max-width: 100% !important; max-height: 100% !important; object-fit: contain !important; } #generate-btn, #save-btn { font-size: 100% !important; padding: 12px 20px !important; min-height: unset !important; height: auto !important; } }#col-container { margin: 0 auto; max-width: 700px; }#sticky-controls { position: sticky; top: 0; z-index: 100; background: var(--body-background-fill); padding-top: 6px; padding-bottom: 6px;}"""
with gr.Blocks(css=css) as demo: with gr.Column(elem_id="col-container"): with gr.Row(): run_button = gr.Button("Generate", variant="primary", elem_id="generate-btn") download_button = gr.DownloadButton("Save", visible=False, elem_id="save-btn")
result = gr.Image(show_label=False, width=WIDTH, height=HEIGHT, elem_id="result-container")
prompt = gr.Textbox( label=None, show_label=False, placeholder="Describe the image...", lines=2, ) with gr.Column(elem_id="sticky-controls"): prompt = gr.Textbox( label=None, show_label=False, placeholder="Describe the image...", lines=2, ) with gr.Row(): run_button = gr.Button("Generate", variant="primary") download_button = gr.DownloadButton("Save", visible=False)
result = gr.Image(show_label=False, width=WIDTH, height=HEIGHT)
gr.on( triggers=[run_button.click, prompt.submit],app.py+25-14