Update app.py
Browse files
app.py
CHANGED
@@ -748,7 +748,15 @@ sd = {k.replace("model.diffusion_model.", ""): v for k, v in sd.items() if "mode
|
|
748 |
model = Flux().to(dtype=torch.bfloat16, device="cuda")
|
749 |
result = model.load_state_dict(sd)
|
750 |
model_zero_init = False
|
751 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
752 |
|
753 |
# model = Flux().to(dtype=torch.bfloat16, device="cuda")
|
754 |
# result = model.load_state_dict(load_file("/storage/dev/nyanko/flux-dev/flux1-dev.sft"))
|
@@ -766,11 +774,6 @@ def generate_image(
|
|
766 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
767 |
torch_device = torch.device(device)
|
768 |
|
769 |
-
global model, model_zero_init
|
770 |
-
if not model_zero_init:
|
771 |
-
model = model.to(torch_device)
|
772 |
-
model_zero_init = True
|
773 |
-
|
774 |
if do_img2img and init_image is not None:
|
775 |
init_image = get_image(init_image)
|
776 |
if resize_img:
|
|
|
748 |
model = Flux().to(dtype=torch.bfloat16, device="cuda")
|
749 |
result = model.load_state_dict(sd)
|
750 |
model_zero_init = False
|
751 |
+
|
752 |
+
@spaces.GPU()
|
753 |
+
def apply_nf4_storage():
|
754 |
+
global model, model_zero_init
|
755 |
+
if not model_zero_init:
|
756 |
+
model = model.to(torch_device)
|
757 |
+
model_zero_init = True
|
758 |
+
|
759 |
+
apply_nf4_storage()
|
760 |
|
761 |
# model = Flux().to(dtype=torch.bfloat16, device="cuda")
|
762 |
# result = model.load_state_dict(load_file("/storage/dev/nyanko/flux-dev/flux1-dev.sft"))
|
|
|
774 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
775 |
torch_device = torch.device(device)
|
776 |
|
|
|
|
|
|
|
|
|
|
|
777 |
if do_img2img and init_image is not None:
|
778 |
init_image = get_image(init_image)
|
779 |
if resize_img:
|