jamino30 commited on
Commit
caf9141
1 Parent(s): 01dd5e7

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -25,12 +25,12 @@ style_files = os.listdir('./style_images')
25
  style_options = {' '.join(style_file.split('.')[0].split('_')): f'./style_images/{style_file}' for style_file in style_files}
26
 
27
  @spaces.GPU(duration=35)
28
- def inference(content_image, style_image, style_strength, progress=gr.Progress(track_tqdm=True)):
29
  yield None
30
  print('-'*15)
31
  print('DATETIME:', datetime.datetime.now())
32
  print('STYLE:', style_image)
33
- img_size = 512
34
  content_img, original_size = load_img(content_image, img_size)
35
  content_img = content_img.to(device)
36
  style_img = load_img_from_path(style_options[style_image], img_size)[0].to(device)
@@ -99,17 +99,19 @@ with gr.Blocks(css=css) as demo:
99
  low_button = gr.Button('Low').click(fn=lambda: set_slider(10), outputs=[style_strength_slider])
100
  medium_button = gr.Button('Medium').click(fn=lambda: set_slider(50), outputs=[style_strength_slider])
101
  high_button = gr.Button('High').click(fn=lambda: set_slider(100), outputs=[style_strength_slider])
 
 
102
  submit_button = gr.Button('Submit')
103
 
104
- submit_button.click(fn=inference, inputs=[content_and_output, style_dropdown, style_strength_slider], outputs=[content_and_output])
105
 
106
  examples = gr.Examples(
107
  examples=[
108
- ['./content_images/TajMahal.jpg', 'Starry Night', 75, False],
109
- ['./content_images/GoldenRetriever.jpg', 'Lego Bricks', 50, False],
110
- ['./content_images/SeaTurtle.jpg', 'Mosaic', 100, False]
111
  ],
112
- inputs=[content_and_output, style_dropdown, style_strength_slider]
113
  )
114
 
115
  # disable queue
 
25
  style_options = {' '.join(style_file.split('.')[0].split('_')): f'./style_images/{style_file}' for style_file in style_files}
26
 
27
  @spaces.GPU(duration=35)
28
+ def inference(content_image, style_image, style_strength, output_quality, progress=gr.Progress(track_tqdm=True)):
29
  yield None
30
  print('-'*15)
31
  print('DATETIME:', datetime.datetime.now())
32
  print('STYLE:', style_image)
33
+ img_size = 1024 if output_quality else 512
34
  content_img, original_size = load_img(content_image, img_size)
35
  content_img = content_img.to(device)
36
  style_img = load_img_from_path(style_options[style_image], img_size)[0].to(device)
 
99
  low_button = gr.Button('Low').click(fn=lambda: set_slider(10), outputs=[style_strength_slider])
100
  medium_button = gr.Button('Medium').click(fn=lambda: set_slider(50), outputs=[style_strength_slider])
101
  high_button = gr.Button('High').click(fn=lambda: set_slider(100), outputs=[style_strength_slider])
102
+ with gr.Group():
103
+ output_quality = gr.Checkbox(label='High Quality', info='Note: This takes longer, but improves output image quality')
104
  submit_button = gr.Button('Submit')
105
 
106
+ submit_button.click(fn=inference, inputs=[content_and_output, style_dropdown, style_strength_slider, output_quality], outputs=[content_and_output])
107
 
108
  examples = gr.Examples(
109
  examples=[
110
+ ['./content_images/TajMahal.jpg', 'Starry Night', 75, True],
111
+ ['./content_images/GoldenRetriever.jpg', 'Lego Bricks', 50, True],
112
+ ['./content_images/SeaTurtle.jpg', 'Mosaic', 100, True]
113
  ],
114
+ inputs=[content_and_output, style_dropdown, style_strength_slider, output_quality]
115
  )
116
 
117
  # disable queue