Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -13,9 +13,11 @@ from PIL import Image
|
|
13 |
from diffusers import DiffusionPipeline, FlowMatchEulerDiscreteScheduler, FluxTransformer2DModel
|
14 |
from transformers import CLIPTextModel, CLIPTokenizer,T5EncoderModel, T5TokenizerFast
|
15 |
|
|
|
|
|
16 |
# Define the device
|
17 |
dtype = torch.bfloat16
|
18 |
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
19 |
|
20 |
# Use the 'waffles' environment variable as the access token
|
21 |
hf_token = os.getenv('waffles')
|
@@ -30,18 +32,11 @@ with open('loras.json', 'r') as f:
|
|
30 |
|
31 |
# Initialize the base model with authentication and specify the device
|
32 |
# Initialize the base model with authentication and specify the device
|
33 |
-
pipe = DiffusionPipeline.from_pretrained("sayakpaul/FLUX.1-merged", torch_dtype=dtype, token=hf_token, trust_remote_code=True, device_map='balanced').to(
|
34 |
|
35 |
MAX_SEED = np.iinfo(np.int32).max
|
36 |
MAX_IMAGE_SIZE = 2048
|
37 |
|
38 |
-
max_memory = get_balanced_memory(
|
39 |
-
model,
|
40 |
-
max_memory=None,
|
41 |
-
no_split_module_classes=["DecoderLayer", "Attention", "MLP", "LayerNorm", "Linear"],
|
42 |
-
dtype='float16',
|
43 |
-
low_zero=False,
|
44 |
-
)
|
45 |
|
46 |
device_map = infer_auto_device_map(
|
47 |
model,
|
@@ -50,7 +45,7 @@ device_map = infer_auto_device_map(
|
|
50 |
dtype='float16'
|
51 |
)
|
52 |
|
53 |
-
model = dispatch_model(model, device_map='
|
54 |
|
55 |
class calculateDuration:
|
56 |
def __init__(self, activity_name=""):
|
|
|
13 |
from diffusers import DiffusionPipeline, FlowMatchEulerDiscreteScheduler, FluxTransformer2DModel
|
14 |
from transformers import CLIPTextModel, CLIPTokenizer,T5EncoderModel, T5TokenizerFast
|
15 |
|
16 |
+
|
17 |
+
|
18 |
# Define the device
|
19 |
dtype = torch.bfloat16
|
20 |
+
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
21 |
|
22 |
# Use the 'waffles' environment variable as the access token
|
23 |
hf_token = os.getenv('waffles')
|
|
|
32 |
|
33 |
# Initialize the base model with authentication and specify the device
|
34 |
# Initialize the base model with authentication and specify the device
|
35 |
+
pipe = DiffusionPipeline.from_pretrained("sayakpaul/FLUX.1-merged", torch_dtype=dtype, token=hf_token, trust_remote_code=True, device_map='balanced').to("torch.cuda:0")
|
36 |
|
37 |
MAX_SEED = np.iinfo(np.int32).max
|
38 |
MAX_IMAGE_SIZE = 2048
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
device_map = infer_auto_device_map(
|
42 |
model,
|
|
|
45 |
dtype='float16'
|
46 |
)
|
47 |
|
48 |
+
model = dispatch_model(model, device_map='torch.cuda:0')
|
49 |
|
50 |
class calculateDuration:
|
51 |
def __init__(self, activity_name=""):
|