clementchadebec commited on
Commit
e5efe2c
1 Parent(s): b3f688a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -10,6 +10,7 @@ from diffusers import FluxControlNetModel
10
  from diffusers.pipelines import FluxControlNetPipeline
11
  from gradio_imageslider import ImageSlider
12
  from PIL import Image
 
13
 
14
  css = """
15
  #col-container {
@@ -25,12 +26,24 @@ else:
25
  power_device = "CPU"
26
  device = "cpu"
27
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  # Load pipeline
29
  controlnet = FluxControlNetModel.from_pretrained(
30
  "jasperai/Flux.1-dev-Controlnet-Upscaler", torch_dtype=torch.bfloat16
31
  ).to(device)
32
  pipe = FluxControlNetPipeline.from_pretrained(
33
- "black-forest-labs/FLUX.1-dev", controlnet=controlnet, torch_dtype=torch.bfloat16
34
  )
35
  pipe.to(device)
36
 
 
10
  from diffusers.pipelines import FluxControlNetPipeline
11
  from gradio_imageslider import ImageSlider
12
  from PIL import Image
13
+ from huggingface_hub import snapshot_download
14
 
15
  css = """
16
  #col-container {
 
26
  power_device = "CPU"
27
  device = "cpu"
28
 
29
+
30
+ huggingface_token = os.getenv("HUGGINFACE_TOKEN")
31
+
32
+ model_path = snapshot_download(
33
+ repo_id="black-forest-labs/FLUX.1-dev",
34
+ repo_type="model",
35
+ ignore_patterns=["*.md", "*..gitattributes"],
36
+ local_dir="FLUX.1-dev",
37
+ token=huggingface_token, # type a new token-id.
38
+ )
39
+
40
+
41
  # Load pipeline
42
  controlnet = FluxControlNetModel.from_pretrained(
43
  "jasperai/Flux.1-dev-Controlnet-Upscaler", torch_dtype=torch.bfloat16
44
  ).to(device)
45
  pipe = FluxControlNetPipeline.from_pretrained(
46
+ model_path, controlnet=controlnet, torch_dtype=torch.bfloat16
47
  )
48
  pipe.to(device)
49