| import os |
| import tempfile |
| import gradio as gr |
| import torch |
| from diffusers import BriaFiboEditPipeline |
|
|
| hf_token = os.getenv("HF_TOKEN") |
|
|
| def download_model(): |
| with tempfile.TemporaryDirectory() as tmp_cache: |
| BriaFiboEditPipeline.from_pretrained( |
| "briaai/Fibo-Edit", |
| torch_dtype=torch.bfloat16, |
| force_download=True, |
| cache_dir=tmp_cache, |
| token=hf_token |
| ) |
|
|
| def on_load(): |
| download_model() |
|
|
|
|
| CUSTOM_CSS = """ |
| html, body, .gradio-container, .gradio-style, .html-container, .hide-container, .column, .fillable, .bria-iframe { |
| width: 100% !important; |
| max-width: unset !important; |
| height: 100% !important; |
| margin: 0 !important; |
| padding-left: 0 !important; |
| padding-right: 0 !important; |
| padding-top: 0 !important; |
| border: 0 !important; |
| } |
| footer { |
| visibility: hidden !important; |
| height: 0 !important; |
| } |
| """ |
|
|
| with gr.Blocks( |
| title="BRIA FIBO Edit Labs", |
| css=CUSTOM_CSS, |
| ) as demo: |
| gr.HTML(""" |
| <iframe class="bria-iframe" src="https://prod.iframe.platform.bria.ai/?iframeId=24b9171e-11f9-4fbd-b0b5-f8d784981c01"></iframe> |
| """) |
| demo.load(on_load) |
|
|
| demo.launch() |
|
|