Spaces:
Paused
Paused
Upload 4 files
Browse files- README.md +1 -1
- app.py +19 -7
- requirements.txt +2 -1
README.md
CHANGED
@@ -4,7 +4,7 @@ emoji: 🖥️
|
|
4 |
colorFrom: yellow
|
5 |
colorTo: pink
|
6 |
sdk: gradio
|
7 |
-
sdk_version:
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
|
|
4 |
colorFrom: yellow
|
5 |
colorTo: pink
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 4.44.1
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
app.py
CHANGED
@@ -6,6 +6,7 @@ import torch
|
|
6 |
from diffusers import DiffusionPipeline, FlowMatchEulerDiscreteScheduler, AutoencoderTiny, AutoencoderKL
|
7 |
from transformers import CLIPTextModel, CLIPTokenizer,T5EncoderModel, T5TokenizerFast
|
8 |
from live_preview_helpers import calculate_shift, retrieve_timesteps, flux_pipe_call_that_returns_an_iterable_of_images
|
|
|
9 |
|
10 |
dtype = torch.bfloat16
|
11 |
#model_id = "black-forest-labs/FLUX.1-dev"
|
@@ -23,14 +24,24 @@ MAX_IMAGE_SIZE = 2048
|
|
23 |
|
24 |
pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
|
25 |
|
26 |
-
@spaces.GPU(duration=
|
27 |
def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, guidance_scale=3.5, num_inference_steps=28, sigmas=0.95, progress=gr.Progress(track_tqdm=True)):
|
28 |
if randomize_seed:
|
29 |
seed = random.randint(0, MAX_SEED)
|
30 |
generator = torch.Generator().manual_seed(seed)
|
31 |
|
32 |
#for img in pipe.flux_pipe_call_that_returns_an_iterable_of_images(
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
prompt=prompt,
|
35 |
guidance_scale=guidance_scale,
|
36 |
num_inference_steps=num_inference_steps,
|
@@ -39,8 +50,8 @@ def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, guidan
|
|
39 |
generator=generator,
|
40 |
output_type="pil",
|
41 |
mul_sigmas=sigmas
|
42 |
-
).images
|
43 |
-
|
44 |
|
45 |
examples = [
|
46 |
"a tiny astronaut hatching from an egg on the moon",
|
@@ -75,7 +86,8 @@ with gr.Blocks(css=css) as demo:
|
|
75 |
|
76 |
run_button = gr.Button("Run", scale=0)
|
77 |
|
78 |
-
result = gr.Image(label="Result", show_label=False)
|
|
|
79 |
|
80 |
with gr.Accordion("Advanced Settings", open=True):
|
81 |
sigmas = gr.Slider(
|
@@ -97,7 +109,7 @@ with gr.Blocks(css=css) as demo:
|
|
97 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=False)
|
98 |
|
99 |
with gr.Row():
|
100 |
-
|
101 |
width = gr.Slider(
|
102 |
label="Width",
|
103 |
minimum=256,
|
@@ -147,4 +159,4 @@ with gr.Blocks(css=css) as demo:
|
|
147 |
outputs = [result, seed]
|
148 |
)
|
149 |
|
150 |
-
demo.launch(
|
|
|
6 |
from diffusers import DiffusionPipeline, FlowMatchEulerDiscreteScheduler, AutoencoderTiny, AutoencoderKL
|
7 |
from transformers import CLIPTextModel, CLIPTokenizer,T5EncoderModel, T5TokenizerFast
|
8 |
from live_preview_helpers import calculate_shift, retrieve_timesteps, flux_pipe_call_that_returns_an_iterable_of_images
|
9 |
+
from gradio_imageslider import ImageSlider
|
10 |
|
11 |
dtype = torch.bfloat16
|
12 |
#model_id = "black-forest-labs/FLUX.1-dev"
|
|
|
24 |
|
25 |
pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
|
26 |
|
27 |
+
@spaces.GPU(duration=90)
|
28 |
def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, guidance_scale=3.5, num_inference_steps=28, sigmas=0.95, progress=gr.Progress(track_tqdm=True)):
|
29 |
if randomize_seed:
|
30 |
seed = random.randint(0, MAX_SEED)
|
31 |
generator = torch.Generator().manual_seed(seed)
|
32 |
|
33 |
#for img in pipe.flux_pipe_call_that_returns_an_iterable_of_images(
|
34 |
+
image_def = pipe(
|
35 |
+
prompt=prompt,
|
36 |
+
guidance_scale=guidance_scale,
|
37 |
+
num_inference_steps=num_inference_steps,
|
38 |
+
width=width,
|
39 |
+
height=height,
|
40 |
+
generator=generator,
|
41 |
+
output_type="pil",
|
42 |
+
).images[0]
|
43 |
+
# yield img, seed
|
44 |
+
image_sigmas = pipe(
|
45 |
prompt=prompt,
|
46 |
guidance_scale=guidance_scale,
|
47 |
num_inference_steps=num_inference_steps,
|
|
|
50 |
generator=generator,
|
51 |
output_type="pil",
|
52 |
mul_sigmas=sigmas
|
53 |
+
).images[0]
|
54 |
+
return [image_def, image_sigmas], seed
|
55 |
|
56 |
examples = [
|
57 |
"a tiny astronaut hatching from an egg on the moon",
|
|
|
86 |
|
87 |
run_button = gr.Button("Run", scale=0)
|
88 |
|
89 |
+
#result = gr.Image(label="Result", show_label=False)
|
90 |
+
result = ImageSlider(label="Result", show_label=False, type="pil", slider_color="pink")
|
91 |
|
92 |
with gr.Accordion("Advanced Settings", open=True):
|
93 |
sigmas = gr.Slider(
|
|
|
109 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=False)
|
110 |
|
111 |
with gr.Row():
|
112 |
+
|
113 |
width = gr.Slider(
|
114 |
label="Width",
|
115 |
minimum=256,
|
|
|
159 |
outputs = [result, seed]
|
160 |
)
|
161 |
|
162 |
+
demo.launch()
|
requirements.txt
CHANGED
@@ -4,4 +4,5 @@ git+https://github.com/huggingface/diffusers.git@6b1c4a766b7f83fe06ddb9bbb58c112
|
|
4 |
torch
|
5 |
transformers==4.42.4
|
6 |
xformers
|
7 |
-
sentencepiece
|
|
|
|
4 |
torch
|
5 |
transformers==4.42.4
|
6 |
xformers
|
7 |
+
sentencepiece
|
8 |
+
gradio_imageslider
|