Spaces:
Paused
Paused
MohamedRashad
commited on
Commit
·
ea6cb86
1
Parent(s):
ccce713
chore: Update GPU duration in enhance_image function and clean up commented code
Browse files
app.py
CHANGED
@@ -12,35 +12,35 @@ pipe = FluxPipeline.from_pretrained(
|
|
12 |
text_encoder_2=None,
|
13 |
torch_dtype=torch.bfloat16
|
14 |
).to("cuda")
|
15 |
-
pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
|
16 |
# pipe.enable_sequential_cpu_offload()
|
17 |
|
18 |
-
@spaces.GPU
|
19 |
def enhance_image(image_path, keep_aspect_ratio=False):
|
20 |
print(image_path)
|
21 |
image = load_image(image_path)
|
22 |
print(image.size)
|
23 |
width, height = image.size if keep_aspect_ratio else (None, None)
|
24 |
pipe_prior_output = pipe_prior_redux(image)
|
25 |
-
for img in pipe.flux_pipe_call_that_returns_an_iterable_of_images(
|
26 |
-
guidance_scale=2.5,
|
27 |
-
num_inference_steps=50,
|
28 |
-
width=width,
|
29 |
-
height=height,
|
30 |
-
generator=torch.Generator("cpu").manual_seed(0),
|
31 |
-
output_type="pil",
|
32 |
-
**pipe_prior_output
|
33 |
-
):
|
34 |
-
yield img
|
35 |
-
# images = pipe(
|
36 |
-
# height=height,
|
37 |
-
# width=width,
|
38 |
# guidance_scale=2.5,
|
39 |
# num_inference_steps=50,
|
|
|
|
|
40 |
# generator=torch.Generator("cpu").manual_seed(0),
|
41 |
-
#
|
42 |
-
#
|
43 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
|
46 |
with gr.Blocks(title="Flux.1 Dev Redux") as demo:
|
|
|
12 |
text_encoder_2=None,
|
13 |
torch_dtype=torch.bfloat16
|
14 |
).to("cuda")
|
15 |
+
# pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
|
16 |
# pipe.enable_sequential_cpu_offload()
|
17 |
|
18 |
+
@spaces.GPU(duration=120)
|
19 |
def enhance_image(image_path, keep_aspect_ratio=False):
|
20 |
print(image_path)
|
21 |
image = load_image(image_path)
|
22 |
print(image.size)
|
23 |
width, height = image.size if keep_aspect_ratio else (None, None)
|
24 |
pipe_prior_output = pipe_prior_redux(image)
|
25 |
+
# for img in pipe.flux_pipe_call_that_returns_an_iterable_of_images(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
# guidance_scale=2.5,
|
27 |
# num_inference_steps=50,
|
28 |
+
# width=width,
|
29 |
+
# height=height,
|
30 |
# generator=torch.Generator("cpu").manual_seed(0),
|
31 |
+
# output_type="pil",
|
32 |
+
# **pipe_prior_output
|
33 |
+
# ):
|
34 |
+
# yield img
|
35 |
+
images = pipe(
|
36 |
+
height=height,
|
37 |
+
width=width,
|
38 |
+
guidance_scale=2.5,
|
39 |
+
num_inference_steps=25,
|
40 |
+
generator=torch.Generator("cpu").manual_seed(0),
|
41 |
+
**pipe_prior_output,
|
42 |
+
).images
|
43 |
+
return images[0]
|
44 |
|
45 |
|
46 |
with gr.Blocks(title="Flux.1 Dev Redux") as demo:
|