Spaces:
Running
on
Zero
Running
on
Zero
Update backend.py
Browse files- flux_app/backend.py +4 -4
flux_app/backend.py
CHANGED
@@ -30,7 +30,7 @@ class ModelManager:
|
|
30 |
|
31 |
self.initialize_models()
|
32 |
|
33 |
-
@spaces.GPU(duration=
|
34 |
def initialize_models(self):
|
35 |
"""Initializes the diffusion pipelines and autoencoders."""
|
36 |
self.taef1 = AutoencoderTiny.from_pretrained(TAEF1_MODEL, torch_dtype=DTYPE).to(DEVICE)
|
@@ -48,10 +48,10 @@ class ModelManager:
|
|
48 |
).to(DEVICE)
|
49 |
|
50 |
setattr(self.pipe, "flux_pipe_call_that_returns_an_iterable_of_images", self.process_images)
|
51 |
-
@spaces.GPU(duration=
|
52 |
def process_images(self, *args, **kwargs):
|
53 |
return flux_pipe_call_that_returns_an_iterable_of_images(self.pipe, *args, **kwargs)
|
54 |
-
@spaces.GPU(duration=
|
55 |
def generate_image(self, prompt_mash, steps, seed, cfg_scale, width, height, lora_scale):
|
56 |
"""Generates an image using the FLUX pipeline."""
|
57 |
self.pipe.to(DEVICE) # Ensure pipeline is on GPU
|
@@ -70,7 +70,7 @@ class ModelManager:
|
|
70 |
good_vae=self.good_vae,
|
71 |
):
|
72 |
yield img
|
73 |
-
@spaces.GPU(duration=
|
74 |
def generate_image_to_image(self, prompt_mash, image_input_path, image_strength, steps, cfg_scale, width, height, lora_scale, seed):
|
75 |
"""Generates an image using image-to-image processing."""
|
76 |
generator = torch.Generator(device=DEVICE).manual_seed(seed)
|
|
|
30 |
|
31 |
self.initialize_models()
|
32 |
|
33 |
+
@spaces.GPU(duration=100)
|
34 |
def initialize_models(self):
|
35 |
"""Initializes the diffusion pipelines and autoencoders."""
|
36 |
self.taef1 = AutoencoderTiny.from_pretrained(TAEF1_MODEL, torch_dtype=DTYPE).to(DEVICE)
|
|
|
48 |
).to(DEVICE)
|
49 |
|
50 |
setattr(self.pipe, "flux_pipe_call_that_returns_an_iterable_of_images", self.process_images)
|
51 |
+
@spaces.GPU(duration=100)
|
52 |
def process_images(self, *args, **kwargs):
|
53 |
return flux_pipe_call_that_returns_an_iterable_of_images(self.pipe, *args, **kwargs)
|
54 |
+
@spaces.GPU(duration=100)
|
55 |
def generate_image(self, prompt_mash, steps, seed, cfg_scale, width, height, lora_scale):
|
56 |
"""Generates an image using the FLUX pipeline."""
|
57 |
self.pipe.to(DEVICE) # Ensure pipeline is on GPU
|
|
|
70 |
good_vae=self.good_vae,
|
71 |
):
|
72 |
yield img
|
73 |
+
@spaces.GPU(duration=100)
|
74 |
def generate_image_to_image(self, prompt_mash, image_input_path, image_strength, steps, cfg_scale, width, height, lora_scale, seed):
|
75 |
"""Generates an image using image-to-image processing."""
|
76 |
generator = torch.Generator(device=DEVICE).manual_seed(seed)
|