Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -128,7 +128,17 @@ def infer(
|
|
128 |
return [true_input_image, image, seed]
|
129 |
|
130 |
|
131 |
-
with gr.Blocks(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
with gr.Row():
|
133 |
run_button = gr.Button(value="Run")
|
134 |
|
@@ -137,25 +147,25 @@ with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as demo:
|
|
137 |
input_im = gr.Image(label="Input Image", type="pil")
|
138 |
with gr.Column(scale=1):
|
139 |
num_inference_steps = gr.Slider(
|
140 |
-
label="Steps",
|
141 |
-
minimum=
|
142 |
-
maximum=
|
143 |
step=1,
|
144 |
-
value=
|
145 |
)
|
146 |
upscale_factor = gr.Slider(
|
147 |
-
label="
|
148 |
minimum=1,
|
149 |
-
maximum=
|
150 |
step=1,
|
151 |
-
value=
|
152 |
)
|
153 |
controlnet_conditioning_scale = gr.Slider(
|
154 |
-
label="
|
155 |
minimum=0.1,
|
156 |
-
maximum=
|
157 |
step=0.1,
|
158 |
-
value=0.
|
159 |
)
|
160 |
seed = gr.Slider(
|
161 |
label="Seed",
|
@@ -164,17 +174,20 @@ with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as demo:
|
|
164 |
step=1,
|
165 |
value=42,
|
166 |
)
|
167 |
-
|
|
|
168 |
|
169 |
with gr.Row():
|
170 |
-
result = ImageSlider(label="
|
171 |
|
172 |
-
current_dir = os.path.dirname(os.path.abspath(__file__))
|
173 |
-
|
174 |
examples = gr.Examples(
|
175 |
examples=[
|
176 |
-
|
177 |
-
[42, False,
|
|
|
|
|
|
|
|
|
178 |
],
|
179 |
inputs=[
|
180 |
seed,
|
@@ -186,9 +199,33 @@ with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as demo:
|
|
186 |
],
|
187 |
fn=infer,
|
188 |
outputs=result,
|
189 |
-
cache_examples=
|
190 |
)
|
191 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
gr.on(
|
193 |
[run_button.click],
|
194 |
fn=infer,
|
@@ -202,6 +239,7 @@ with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as demo:
|
|
202 |
],
|
203 |
outputs=result,
|
204 |
show_api=False,
|
|
|
205 |
)
|
206 |
|
207 |
demo.queue().launch(share=False, show_api=False)
|
|
|
128 |
return [true_input_image, image, seed]
|
129 |
|
130 |
|
131 |
+
with gr.Blocks(css=css) as demo:
|
132 |
+
# with gr.Column(elem_id="col-container"):
|
133 |
+
gr.Markdown(
|
134 |
+
f"""
|
135 |
+
# ⚡ Flux.1-dev Upscaler ControlNet ⚡
|
136 |
+
This is an interactive demo of [Flux.1-dev Upscaler ControlNet](https://huggingface.co/jasperai/Flux.1-dev-Controlnet-Upscaler) taking as input a low resolution image to generate a high resolution image.
|
137 |
+
Currently running on {power_device}.
|
138 |
+
*Note*: Even though the model can handle higher resolution images, due to GPU memory constraints, this demo was limited to a generated output not exceeding a pixel budget of 1024x1024. If the requested size exceeds that limit, the input will be first resized keeping the aspect ratio such that the output of the controlNet model does not exceed the allocated pixel budget. The output is then resized to the targeted shape using a simple resizing. This may explain some artifacts for high resolution input. To adress this, run the demo locally or consider implementing a tiling strategy. Happy upscaling! 🚀
|
139 |
+
"""
|
140 |
+
)
|
141 |
+
|
142 |
with gr.Row():
|
143 |
run_button = gr.Button(value="Run")
|
144 |
|
|
|
147 |
input_im = gr.Image(label="Input Image", type="pil")
|
148 |
with gr.Column(scale=1):
|
149 |
num_inference_steps = gr.Slider(
|
150 |
+
label="Number of Inference Steps",
|
151 |
+
minimum=8,
|
152 |
+
maximum=50,
|
153 |
step=1,
|
154 |
+
value=28,
|
155 |
)
|
156 |
upscale_factor = gr.Slider(
|
157 |
+
label="Upscale Factor",
|
158 |
minimum=1,
|
159 |
+
maximum=4,
|
160 |
step=1,
|
161 |
+
value=4,
|
162 |
)
|
163 |
controlnet_conditioning_scale = gr.Slider(
|
164 |
+
label="Controlnet Conditioning Scale",
|
165 |
minimum=0.1,
|
166 |
+
maximum=1.5,
|
167 |
step=0.1,
|
168 |
+
value=0.6,
|
169 |
)
|
170 |
seed = gr.Slider(
|
171 |
label="Seed",
|
|
|
174 |
step=1,
|
175 |
value=42,
|
176 |
)
|
177 |
+
|
178 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
179 |
|
180 |
with gr.Row():
|
181 |
+
result = ImageSlider(label="Input / Output", type="pil", interactive=True)
|
182 |
|
|
|
|
|
183 |
examples = gr.Examples(
|
184 |
examples=[
|
185 |
+
# [42, False, "examples/image_1.jpg", 28, 4, 0.6],
|
186 |
+
[42, False, "examples/image_2.jpg", 28, 4, 0.6],
|
187 |
+
# [42, False, "examples/image_3.jpg", 28, 4, 0.6],
|
188 |
+
[42, False, "examples/image_4.jpg", 28, 4, 0.6],
|
189 |
+
# [42, False, "examples/image_5.jpg", 28, 4, 0.6],
|
190 |
+
# [42, False, "examples/image_6.jpg", 28, 4, 0.6],
|
191 |
],
|
192 |
inputs=[
|
193 |
seed,
|
|
|
199 |
],
|
200 |
fn=infer,
|
201 |
outputs=result,
|
202 |
+
cache_examples="lazy",
|
203 |
)
|
204 |
|
205 |
+
# examples = gr.Examples(
|
206 |
+
# examples=[
|
207 |
+
# #[42, False, "examples/image_1.jpg", 28, 4, 0.6],
|
208 |
+
# [42, False, "examples/image_2.jpg", 28, 4, 0.6],
|
209 |
+
# #[42, False, "examples/image_3.jpg", 28, 4, 0.6],
|
210 |
+
# #[42, False, "examples/image_4.jpg", 28, 4, 0.6],
|
211 |
+
# [42, False, "examples/image_5.jpg", 28, 4, 0.6],
|
212 |
+
# [42, False, "examples/image_6.jpg", 28, 4, 0.6],
|
213 |
+
# [42, False, "examples/image_7.jpg", 28, 4, 0.6],
|
214 |
+
# ],
|
215 |
+
# inputs=[
|
216 |
+
# seed,
|
217 |
+
# randomize_seed,
|
218 |
+
# input_im,
|
219 |
+
# num_inference_steps,
|
220 |
+
# upscale_factor,
|
221 |
+
# controlnet_conditioning_scale,
|
222 |
+
# ],
|
223 |
+
# )
|
224 |
+
|
225 |
+
gr.Markdown("**Disclaimer:**")
|
226 |
+
gr.Markdown(
|
227 |
+
"This demo is only for research purpose. Jasper cannot be held responsible for the generation of NSFW (Not Safe For Work) content through the use of this demo. Users are solely responsible for any content they create, and it is their obligation to ensure that it adheres to appropriate and ethical standards. Jasper provides the tools, but the responsibility for their use lies with the individual user."
|
228 |
+
)
|
229 |
gr.on(
|
230 |
[run_button.click],
|
231 |
fn=infer,
|
|
|
239 |
],
|
240 |
outputs=result,
|
241 |
show_api=False,
|
242 |
+
# show_progress="minimal",
|
243 |
)
|
244 |
|
245 |
demo.queue().launch(share=False, show_api=False)
|