vilarin commited on
Commit
d9334b6
1 Parent(s): 703c17f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -4,9 +4,9 @@ import gradio as gr
4
  import torch
5
  import numpy as np
6
  import random
7
- from diffusers import FluxPipeline, FluxTransformer2DModel
8
- import transformers
9
  from translatepy import Translator
 
10
 
11
 
12
  os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
@@ -29,13 +29,11 @@ JS = """function () {
29
  }
30
  }"""
31
 
32
- transformer = FluxTransformer2DModel.from_pretrained("sayakpaul/FLUX.1-merged", torch_dtype=torch.bfloat16)
33
-
34
  if torch.cuda.is_available():
35
- pipe = FluxPipeline.from_pretrained(
36
- model,
37
- transformer=transformer,
38
- torch_dtype=torch.bfloat16).to("cuda")
39
 
40
  # Function
41
  @spaces.GPU(duration=120)
@@ -93,7 +91,7 @@ examples = [
93
 
94
  with gr.Blocks(css=CSS, js=JS, theme="soft") as demo:
95
  gr.HTML("<h1><center>Flux Labs</center></h1>")
96
- gr.HTML("<p><center>Model Now: <a href='https://huggingface.co/sayakpaul/FLUX.1-merged'>FLUX.1 Merged</a><br>🙇‍♂️Frequent model changes</center></p>")
97
  with gr.Row():
98
  with gr.Column(scale=4):
99
  img = gr.Gallery(label='flux Generated Image', columns = 1, preview=True, height=600)
 
4
  import torch
5
  import numpy as np
6
  import random
7
+ from diffusers import FluxPipeline
 
8
  from translatepy import Translator
9
+ from huggingface_hub import hf_hub_download
10
 
11
 
12
  os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
 
29
  }
30
  }"""
31
 
 
 
32
  if torch.cuda.is_available():
33
+ pipe = FluxPipeline.from_pretrained(model, torch_dtype=torch.bfloat16)
34
+ pipe.load_lora_weights(hf_hub_download("ByteDance/Hyper-SD", "Hyper-FLUX.1-dev-8steps-lora.safetensors"))
35
+ pipe.fuse_lora(lora_scale=0.125)
36
+ pipe.to(device="cuda", dtype=torch.bfloat16)
37
 
38
  # Function
39
  @spaces.GPU(duration=120)
 
91
 
92
  with gr.Blocks(css=CSS, js=JS, theme="soft") as demo:
93
  gr.HTML("<h1><center>Flux Labs</center></h1>")
94
+ gr.HTML("<p><center>Model Now: Hyper-FLUX-8steps-LoRA<br>🙇‍♂️Frequent model changes</center></p>")
95
  with gr.Row():
96
  with gr.Column(scale=4):
97
  img = gr.Gallery(label='flux Generated Image', columns = 1, preview=True, height=600)