Update app.py
Browse files
app.py
CHANGED
@@ -1,108 +1,108 @@
|
|
1 |
-
|
2 |
|
3 |
-
|
4 |
|
5 |
-
import gradio as gr
|
6 |
-
import numpy as np
|
7 |
-
import random
|
8 |
-
import spaces
|
9 |
-
import torch
|
10 |
-
from diffusers import DiffusionPipeline
|
11 |
|
12 |
-
from transformers import pipeline
|
13 |
|
14 |
-
pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell")
|
15 |
|
16 |
-
def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, num_inference_steps=4, progress=gr.Progress(track_tqdm=True)):
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
with gr.Blocks(css=css) as demo:
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
12B param rectified flow transformer distilled from [FLUX.1 [pro]](https://blackforestlabs.ai/) for 4 step generation
|
35 |
-
[[blog](https://blackforestlabs.ai/announcing-black-forest-labs/)] [[model](https://huggingface.co/black-forest-labs/FLUX.1-schnell)]
|
36 |
-
|
37 |
|
38 |
-
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
|
48 |
-
|
49 |
|
50 |
-
|
51 |
|
52 |
-
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
|
62 |
-
|
63 |
|
64 |
-
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
|
82 |
-
|
83 |
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
|
108 |
-
demo.launch()
|
|
|
1 |
+
import gradio as gr
|
2 |
|
3 |
+
gr.load("models/black-forest-labs/FLUX.1-schnell").launch()
|
4 |
|
5 |
+
# import gradio as gr
|
6 |
+
# import numpy as np
|
7 |
+
# import random
|
8 |
+
# import spaces
|
9 |
+
# import torch
|
10 |
+
# from diffusers import DiffusionPipeline
|
11 |
|
12 |
+
# from transformers import pipeline
|
13 |
|
14 |
+
# pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell")
|
15 |
|
16 |
+
# def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, num_inference_steps=4, progress=gr.Progress(track_tqdm=True)):
|
17 |
+
# if randomize_seed:
|
18 |
+
# seed = random.randint(0, MAX_SEED)
|
19 |
+
# generator = torch.Generator().manual_seed(seed)
|
20 |
+
# image = pipe(
|
21 |
+
# prompt = prompt,
|
22 |
+
# width = width,
|
23 |
+
# height = height,
|
24 |
+
# num_inference_steps = num_inference_steps,
|
25 |
+
# generator = generator,
|
26 |
+
# guidance_scale=0.0
|
27 |
+
# ).images[0]
|
28 |
+
# return image, seed
|
29 |
|
30 |
+
# with gr.Blocks(css=css) as demo:
|
31 |
|
32 |
+
# with gr.Column(elem_id="col-container"):
|
33 |
+
# gr.Markdown(f"""# FLUX.1 [schnell]
|
34 |
+
# 12B param rectified flow transformer distilled from [FLUX.1 [pro]](https://blackforestlabs.ai/) for 4 step generation
|
35 |
+
# [[blog](https://blackforestlabs.ai/announcing-black-forest-labs/)] [[model](https://huggingface.co/black-forest-labs/FLUX.1-schnell)]
|
36 |
+
# """)
|
37 |
|
38 |
+
# with gr.Row():
|
39 |
|
40 |
+
# prompt = gr.Text(
|
41 |
+
# label="Prompt",
|
42 |
+
# show_label=False,
|
43 |
+
# max_lines=1,
|
44 |
+
# placeholder="Enter your prompt",
|
45 |
+
# container=False,
|
46 |
+
# )
|
47 |
|
48 |
+
# run_button = gr.Button("Run", scale=0)
|
49 |
|
50 |
+
# result = gr.Image(label="Result", show_label=False)
|
51 |
|
52 |
+
# with gr.Accordion("Advanced Settings", open=False):
|
53 |
|
54 |
+
# seed = gr.Slider(
|
55 |
+
# label="Seed",
|
56 |
+
# minimum=0,
|
57 |
+
# maximum=MAX_SEED,
|
58 |
+
# step=1,
|
59 |
+
# value=0,
|
60 |
+
# )
|
61 |
|
62 |
+
# randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
63 |
|
64 |
+
# with gr.Row():
|
65 |
|
66 |
+
# width = gr.Slider(
|
67 |
+
# label="Width",
|
68 |
+
# minimum=256,
|
69 |
+
# maximum=MAX_IMAGE_SIZE,
|
70 |
+
# step=32,
|
71 |
+
# value=1024,
|
72 |
+
# )
|
73 |
|
74 |
+
# height = gr.Slider(
|
75 |
+
# label="Height",
|
76 |
+
# minimum=256,
|
77 |
+
# maximum=MAX_IMAGE_SIZE,
|
78 |
+
# step=32,
|
79 |
+
# value=1024,
|
80 |
+
# )
|
81 |
|
82 |
+
# with gr.Row():
|
83 |
|
84 |
|
85 |
+
# num_inference_steps = gr.Slider(
|
86 |
+
# label="Number of inference steps",
|
87 |
+
# minimum=1,
|
88 |
+
# maximum=50,
|
89 |
+
# step=1,
|
90 |
+
# value=4,
|
91 |
+
# )
|
92 |
|
93 |
+
# gr.Examples(
|
94 |
+
# examples = examples,
|
95 |
+
# fn = infer,
|
96 |
+
# inputs = [prompt],
|
97 |
+
# outputs = [result, seed],
|
98 |
+
# cache_examples="lazy"
|
99 |
+
# )
|
100 |
|
101 |
+
# gr.on(
|
102 |
+
# triggers=[run_button.click, prompt.submit],
|
103 |
+
# fn = infer,
|
104 |
+
# inputs = [prompt, seed, randomize_seed, width, height, num_inference_steps],
|
105 |
+
# outputs = [result, seed]
|
106 |
+
# )
|
107 |
|
108 |
+
# demo.launch()
|