Spaces:
Running
on
Zero
Running
on
Zero
Upload folder using huggingface_hub
Browse files- app.py +5 -5
- inference.py +1 -1
app.py
CHANGED
@@ -36,7 +36,6 @@ for style_name, style_img_path in style_options.items():
|
|
36 |
@spaces.GPU(duration=15)
|
37 |
def run(content_image, style_name, style_strength=5, progress=gr.Progress(track_tqdm=True)):
|
38 |
yield None
|
39 |
-
img_size = img_size
|
40 |
content_img, original_size = preprocess_img(content_image, img_size)
|
41 |
content_img = content_img.to(device)
|
42 |
|
@@ -71,13 +70,15 @@ css = """
|
|
71 |
}
|
72 |
"""
|
73 |
|
74 |
-
with gr.Blocks(css=css) as demo:
|
75 |
gr.HTML("<h1 style='text-align: center; padding: 10px'>🖼️ Neural Style Transfer</h1>")
|
76 |
with gr.Column(elem_id='container'):
|
77 |
content_and_output = gr.Image(label='Content', show_label=False, type='pil', sources=['upload', 'webcam', 'clipboard'], format='jpg', show_download_button=False)
|
78 |
-
style_dropdown = gr.Radio(choices=list(style_options.keys()), label='Style', value='Starry Night', type='value')
|
79 |
|
80 |
-
|
|
|
|
|
|
|
81 |
|
82 |
submit_button = gr.Button('Submit', variant='primary')
|
83 |
download_button = gr.DownloadButton(label='Download Image', visible=False)
|
@@ -109,7 +110,6 @@ with gr.Blocks(css=css) as demo:
|
|
109 |
examples = gr.Examples(
|
110 |
examples=[
|
111 |
['./content_images/Bridge.jpg', 'Starry Night'],
|
112 |
-
['./content_images/NYCSkyline.jpg', 'Mosaic'],
|
113 |
['./content_images/GoldenRetriever.jpg', 'Great Wave'],
|
114 |
['./content_images/CameraGirl.jpg', 'Bokeh']
|
115 |
],
|
|
|
36 |
@spaces.GPU(duration=15)
|
37 |
def run(content_image, style_name, style_strength=5, progress=gr.Progress(track_tqdm=True)):
|
38 |
yield None
|
|
|
39 |
content_img, original_size = preprocess_img(content_image, img_size)
|
40 |
content_img = content_img.to(device)
|
41 |
|
|
|
70 |
}
|
71 |
"""
|
72 |
|
73 |
+
with gr.Blocks(theme=gr.themes.Base(), css=css) as demo:
|
74 |
gr.HTML("<h1 style='text-align: center; padding: 10px'>🖼️ Neural Style Transfer</h1>")
|
75 |
with gr.Column(elem_id='container'):
|
76 |
content_and_output = gr.Image(label='Content', show_label=False, type='pil', sources=['upload', 'webcam', 'clipboard'], format='jpg', show_download_button=False)
|
|
|
77 |
|
78 |
+
with gr.Group():
|
79 |
+
style_dropdown = gr.Radio(choices=list(style_options.keys()), label='Style', value='Starry Night', type='value')
|
80 |
+
with gr.Group():
|
81 |
+
style_strength_slider = gr.Slider(label='Style Strength', minimum=1, maximum=10, step=1, value=5)
|
82 |
|
83 |
submit_button = gr.Button('Submit', variant='primary')
|
84 |
download_button = gr.DownloadButton(label='Download Image', visible=False)
|
|
|
110 |
examples = gr.Examples(
|
111 |
examples=[
|
112 |
['./content_images/Bridge.jpg', 'Starry Night'],
|
|
|
113 |
['./content_images/GoldenRetriever.jpg', 'Great Wave'],
|
114 |
['./content_images/CameraGirl.jpg', 'Bokeh']
|
115 |
],
|
inference.py
CHANGED
@@ -48,6 +48,6 @@ def inference(
|
|
48 |
|
49 |
for iter in tqdm(range(iterations), desc='The magic is happening ✨'):
|
50 |
optimizer.step(lambda: closure(iter))
|
51 |
-
if iter % 10 == 0: print(f'Loss ({iter
|
52 |
|
53 |
return generated_image
|
|
|
48 |
|
49 |
for iter in tqdm(range(iterations), desc='The magic is happening ✨'):
|
50 |
optimizer.step(lambda: closure(iter))
|
51 |
+
if iter % 10 == 0: print(f'Loss ({iter}):', min_losses[iter])
|
52 |
|
53 |
return generated_image
|