Spaces:
Running
on
Zero
Running
on
Zero
Update flux_schnell.py
Browse files- flux_schnell.py +86 -76
flux_schnell.py
CHANGED
@@ -28,95 +28,105 @@ def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, num_in
|
|
28 |
).images[0]
|
29 |
return image, seed
|
30 |
|
31 |
-
examples = [
|
32 |
-
"a tiny astronaut hatching from an egg on the moon",
|
33 |
-
"a cat holding a sign that says hello world",
|
34 |
-
"an anime illustration of a wiener schnitzel",
|
35 |
-
]
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
with gr.Blocks(css=css) as demo:
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
prompt = gr.Text(
|
55 |
-
label="Prompt",
|
56 |
-
show_label=False,
|
57 |
-
max_lines=1,
|
58 |
-
placeholder="Enter your prompt",
|
59 |
-
container=False,
|
60 |
-
)
|
61 |
-
|
62 |
-
run_button = gr.Button("Run", scale=0)
|
63 |
-
|
64 |
-
result = gr.Image(label="Result", show_label=False)
|
65 |
|
66 |
-
with gr.
|
67 |
-
|
68 |
-
seed = gr.Slider(
|
69 |
-
label="Seed",
|
70 |
-
minimum=0,
|
71 |
-
maximum=MAX_SEED,
|
72 |
-
step=1,
|
73 |
-
value=0,
|
74 |
-
)
|
75 |
-
|
76 |
-
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
77 |
|
78 |
with gr.Row():
|
79 |
|
80 |
-
|
81 |
-
label="
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
)
|
87 |
|
88 |
-
|
89 |
-
label="Height",
|
90 |
-
minimum=256,
|
91 |
-
maximum=MAX_IMAGE_SIZE,
|
92 |
-
step=32,
|
93 |
-
value=1024,
|
94 |
-
)
|
95 |
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
maximum=50,
|
103 |
step=1,
|
104 |
-
value=
|
105 |
)
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
fn = infer,
|
110 |
-
inputs = [prompt],
|
111 |
-
outputs = [result, seed]
|
112 |
-
cache_examples="lazy"
|
113 |
)
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
|
122 |
# demo.launch()
|
|
|
28 |
).images[0]
|
29 |
return image, seed
|
30 |
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
+
def create_flux_tab(image_input):
|
33 |
+
examples = [
|
34 |
+
"a tiny astronaut hatching from an egg on the moon",
|
35 |
+
"a cat holding a sign that says hello world",
|
36 |
+
"an anime illustration of a wiener schnitzel",
|
37 |
+
]
|
|
|
|
|
38 |
|
39 |
+
css="""
|
40 |
+
#col-container {
|
41 |
+
margin: 0 auto;
|
42 |
+
max-width: 520px;
|
43 |
+
}
|
44 |
+
"""
|
45 |
+
|
46 |
+
with gr.Blocks(css=css) as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
+
with gr.Column(elem_id="col-container"):
|
49 |
+
gr.Markdown(f"""# FLUX.1 [schnell]""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
with gr.Row():
|
52 |
|
53 |
+
prompt = gr.Text(
|
54 |
+
label="Prompt",
|
55 |
+
show_label=False,
|
56 |
+
max_lines=1,
|
57 |
+
placeholder="Enter your prompt",
|
58 |
+
container=False,
|
59 |
)
|
60 |
|
61 |
+
run_button = gr.Button("Run", scale=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
+
result = gr.Image(label="Result", show_label=False
|
64 |
+
|
65 |
+
with gr.Row():
|
66 |
+
use_in_text2lipsync_button = gr.Button("이 이미지를 Txt to Lipsync 탭에서 사용하기") # 새로운 버튼 추가
|
67 |
+
|
68 |
+
|
69 |
+
with gr.Accordion("Advanced Settings", open=False):
|
70 |
|
71 |
+
seed = gr.Slider(
|
72 |
+
label="Seed",
|
73 |
+
minimum=0,
|
74 |
+
maximum=MAX_SEED,
|
|
|
75 |
step=1,
|
76 |
+
value=0,
|
77 |
)
|
78 |
+
|
79 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
80 |
+
|
81 |
+
with gr.Row():
|
82 |
+
|
83 |
+
width = gr.Slider(
|
84 |
+
label="Width",
|
85 |
+
minimum=256,
|
86 |
+
maximum=MAX_IMAGE_SIZE,
|
87 |
+
step=32,
|
88 |
+
value=1024,
|
89 |
+
)
|
90 |
+
|
91 |
+
height = gr.Slider(
|
92 |
+
label="Height",
|
93 |
+
minimum=256,
|
94 |
+
maximum=MAX_IMAGE_SIZE,
|
95 |
+
step=32,
|
96 |
+
value=1024,
|
97 |
+
)
|
98 |
+
|
99 |
+
with gr.Row():
|
100 |
+
|
101 |
+
|
102 |
+
num_inference_steps = gr.Slider(
|
103 |
+
label="Number of inference steps",
|
104 |
+
minimum=1,
|
105 |
+
maximum=50,
|
106 |
+
step=1,
|
107 |
+
value=4,
|
108 |
+
)
|
109 |
+
|
110 |
+
gr.Examples(
|
111 |
+
examples = examples,
|
112 |
+
fn = infer,
|
113 |
+
inputs = [prompt],
|
114 |
+
outputs = [result, seed],
|
115 |
+
cache_examples="lazy"
|
116 |
+
)
|
117 |
+
|
118 |
+
gr.on(
|
119 |
+
triggers=[run_button.click, prompt.submit],
|
120 |
fn = infer,
|
121 |
+
inputs = [prompt, seed, randomize_seed, width, height, num_inference_steps],
|
122 |
+
outputs = [result, seed]
|
|
|
123 |
)
|
124 |
+
# 새로운 버튼 클릭 이벤트 정의
|
125 |
+
use_in_text2lipsync_button.click(
|
126 |
+
fn=lambda img: img, # 간단한 람다 함수를 사용하여 이미지를 그대로 전달
|
127 |
+
inputs=[result], # 생성된 이미지를 입력으로 사용
|
128 |
+
outputs=[image_input] # Text to LipSync 탭의 image_input을 업데이트
|
129 |
+
|
130 |
+
return flux_demo
|
131 |
|
132 |
# demo.launch()
|