Spaces:
Running
Running
sab
commited on
Commit
·
3fdd1de
1
Parent(s):
e433aff
fix package reference
Browse files
app.py
CHANGED
@@ -1,18 +1,29 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import torch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
from diffusers.utils import check_min_version
|
5 |
from flux.controlnet_flux import FluxControlNetModel
|
6 |
from flux.transformer_flux import FluxTransformer2DModel
|
7 |
from flux.pipeline_flux_controlnet_inpaint import FluxControlNetInpaintingPipeline
|
8 |
-
import huggingface_hub
|
9 |
|
10 |
# Import configuration
|
11 |
import config
|
12 |
|
13 |
# Login to Hugging Face Hub
|
14 |
-
huggingface_hub.login(os.getenv('
|
15 |
-
check_min_version("0.30.2")
|
16 |
|
17 |
# Load models
|
18 |
transformer = FluxTransformer2DModel.from_pretrained(
|
@@ -28,7 +39,7 @@ pipe = FluxControlNetInpaintingPipeline.from_pretrained(
|
|
28 |
controlnet=controlnet,
|
29 |
transformer=transformer,
|
30 |
torch_dtype=torch.bfloat16
|
31 |
-
)
|
32 |
pipe.transformer.to(torch.bfloat16)
|
33 |
pipe.controlnet.to(torch.bfloat16)
|
34 |
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import torch
|
4 |
+
if os.environ.get("SPACES_ZERO_GPU") is not None:
|
5 |
+
import spaces
|
6 |
+
else:
|
7 |
+
class spaces:
|
8 |
+
@staticmethod
|
9 |
+
def GPU(func):
|
10 |
+
def wrapper(*args, **kwargs):
|
11 |
+
return func(*args, **kwargs)
|
12 |
+
|
13 |
+
return wrapper
|
14 |
+
|
15 |
from diffusers.utils import check_min_version
|
16 |
from flux.controlnet_flux import FluxControlNetModel
|
17 |
from flux.transformer_flux import FluxTransformer2DModel
|
18 |
from flux.pipeline_flux_controlnet_inpaint import FluxControlNetInpaintingPipeline
|
19 |
+
#import huggingface_hub
|
20 |
|
21 |
# Import configuration
|
22 |
import config
|
23 |
|
24 |
# Login to Hugging Face Hub
|
25 |
+
# huggingface_hub.login(os.getenv('HF_TOKEN_FLUX'))
|
26 |
+
# check_min_version("0.30.2")
|
27 |
|
28 |
# Load models
|
29 |
transformer = FluxTransformer2DModel.from_pretrained(
|
|
|
39 |
controlnet=controlnet,
|
40 |
transformer=transformer,
|
41 |
torch_dtype=torch.bfloat16
|
42 |
+
)#.to("cuda")
|
43 |
pipe.transformer.to(torch.bfloat16)
|
44 |
pipe.controlnet.to(torch.bfloat16)
|
45 |
|