Update app.py
Browse files
app.py
CHANGED
@@ -749,18 +749,6 @@ 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 |
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
755 |
-
torch_device = torch.device(device)
|
756 |
-
|
757 |
-
global model, model_zero_init
|
758 |
-
if not model_zero_init:
|
759 |
-
model = model.to(torch_device)
|
760 |
-
model_zero_init = True
|
761 |
-
|
762 |
-
apply_nf4_storage()
|
763 |
-
|
764 |
# model = Flux().to(dtype=torch.bfloat16, device="cuda")
|
765 |
# result = model.load_state_dict(load_file("/storage/dev/nyanko/flux-dev/flux1-dev.sft"))
|
766 |
|
@@ -777,6 +765,11 @@ def generate_image(
|
|
777 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
778 |
torch_device = torch.device(device)
|
779 |
|
|
|
|
|
|
|
|
|
|
|
780 |
if do_img2img and init_image is not None:
|
781 |
init_image = get_image(init_image)
|
782 |
if resize_img:
|
|
|
749 |
result = model.load_state_dict(sd)
|
750 |
model_zero_init = False
|
751 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
752 |
# model = Flux().to(dtype=torch.bfloat16, device="cuda")
|
753 |
# result = model.load_state_dict(load_file("/storage/dev/nyanko/flux-dev/flux1-dev.sft"))
|
754 |
|
|
|
765 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
766 |
torch_device = torch.device(device)
|
767 |
|
768 |
+
global model, model_zero_init
|
769 |
+
if not model_zero_init:
|
770 |
+
model = model.to(torch_device)
|
771 |
+
model_zero_init = True
|
772 |
+
|
773 |
if do_img2img and init_image is not None:
|
774 |
init_image = get_image(init_image)
|
775 |
if resize_img:
|