Spaces:
Running
on
Zero
Running
on
Zero
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
@@ -131,6 +131,9 @@ def inference(content_image, style_image, style_strength, progress=gr.Progress(t
|
|
131 |
yield save_img(generated_img, original_size)
|
132 |
|
133 |
|
|
|
|
|
|
|
134 |
with gr.Blocks(title='🖼️ Neural Style Transfer') as demo:
|
135 |
gr.HTML("<h1 style='text-align: center'>🖼️ Neural Style Transfer</h1>")
|
136 |
with gr.Row():
|
@@ -138,12 +141,19 @@ with gr.Blocks(title='🖼️ Neural Style Transfer') as demo:
|
|
138 |
content_image = gr.Image(label='Content', type='pil', sources=['upload'])
|
139 |
style_dropdown = gr.Dropdown(choices=list(style_options.keys()), label='Style', value='Starry Night', type='value')
|
140 |
with gr.Accordion('Advanced Settings', open=False):
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
submit_button = gr.Button('Submit')
|
143 |
with gr.Column():
|
144 |
output_image = gr.Image(label='Output', show_download_button=True, interactive=False)
|
145 |
|
146 |
-
submit_button.click(fn=inference, inputs=[content_image, style_dropdown,
|
147 |
|
148 |
examples = gr.Examples(
|
149 |
examples=[
|
@@ -158,7 +168,7 @@ with gr.Blocks(title='🖼️ Neural Style Transfer') as demo:
|
|
158 |
['./content_images/NYCSkyline.jpg', 'Oil Painting', 50],
|
159 |
['./content_images/GoldenRetriever.jpg', 'Great Wave', 75],
|
160 |
],
|
161 |
-
inputs=[content_image, style_dropdown,
|
162 |
examples_per_page=len(style_options),
|
163 |
)
|
164 |
|
|
|
131 |
yield save_img(generated_img, original_size)
|
132 |
|
133 |
|
134 |
+
def set_slider(value):
|
135 |
+
return gr.update(value=value)
|
136 |
+
|
137 |
with gr.Blocks(title='🖼️ Neural Style Transfer') as demo:
|
138 |
gr.HTML("<h1 style='text-align: center'>🖼️ Neural Style Transfer</h1>")
|
139 |
with gr.Row():
|
|
|
141 |
content_image = gr.Image(label='Content', type='pil', sources=['upload'])
|
142 |
style_dropdown = gr.Dropdown(choices=list(style_options.keys()), label='Style', value='Starry Night', type='value')
|
143 |
with gr.Accordion('Advanced Settings', open=False):
|
144 |
+
style_strength_slider = gr.Slider(label='Style Strength', minimum=0, maximum=100, step=5, value=50)
|
145 |
+
with gr.Row():
|
146 |
+
low_button = gr.Button('Low')
|
147 |
+
medium_button = gr.Button('Medium')
|
148 |
+
high_button = gr.Button('High')
|
149 |
+
low_button.click(fn=lambda: set_slider(10), outputs=[style_strength_slider])
|
150 |
+
medium_button.click(fn=lambda: set_slider(50), outputs=[style_strength_slider])
|
151 |
+
high_button.click(fn=lambda: set_slider(100), outputs=[style_strength_slider])
|
152 |
submit_button = gr.Button('Submit')
|
153 |
with gr.Column():
|
154 |
output_image = gr.Image(label='Output', show_download_button=True, interactive=False)
|
155 |
|
156 |
+
submit_button.click(fn=inference, inputs=[content_image, style_dropdown, style_strength_slider], outputs=[output_image])
|
157 |
|
158 |
examples = gr.Examples(
|
159 |
examples=[
|
|
|
168 |
['./content_images/NYCSkyline.jpg', 'Oil Painting', 50],
|
169 |
['./content_images/GoldenRetriever.jpg', 'Great Wave', 75],
|
170 |
],
|
171 |
+
inputs=[content_image, style_dropdown, style_strength_slider],
|
172 |
examples_per_page=len(style_options),
|
173 |
)
|
174 |
|