Spaces:
Runtime error
Runtime error
Increased StyleCLIP video length. Added more descriptions.
Browse files- README.md +1 -1
- app.py +13 -7
- generate_videos.py +1 -1
README.md
CHANGED
@@ -4,7 +4,7 @@ emoji: π
|
|
4 |
colorFrom: blue
|
5 |
colorTo: gray
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 3.0.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
|
|
4 |
colorFrom: blue
|
5 |
colorTo: gray
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 3.0.2
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
app.py
CHANGED
@@ -307,14 +307,17 @@ blocks = gr.Blocks()
|
|
307 |
with blocks:
|
308 |
gr.Markdown("<h1><center>StyleGAN-NADA</center></h1>")
|
309 |
gr.Markdown(
|
310 |
-
"
|
311 |
)
|
312 |
gr.Markdown(
|
313 |
-
"
|
|
|
|
|
|
|
|
|
314 |
)
|
315 |
|
316 |
-
|
317 |
-
gr.Markdown("<h4 style='font-size: 110%;margin-top:.5em'>On biases</h4><div>This model relies on StyleGAN and CLIP, both of which are prone to biases such as poor representation of minorities or reinforcement of societal biases, such as gender norms. </div>")
|
318 |
|
319 |
with gr.Row():
|
320 |
input_img = gr.inputs.Image(type="filepath", label="Input image")
|
@@ -330,6 +333,8 @@ with blocks:
|
|
330 |
gr.Markdown("If multiple options are provided, they will be used randomly between images (or sequentially for a video), <u>not</u> together.")
|
331 |
gr.Markdown("Please note that some directions may be entangled. For example, hair length adjustments are likely to also modify the perceived gender.")
|
332 |
|
|
|
|
|
333 |
pose_slider = gr.Slider(label="Pose", minimum=-1, maximum=1, value=0, step=0.05)
|
334 |
smile_slider = gr.Slider(label="Smile", minimum=-1, maximum=1, value=0, step=0.05)
|
335 |
gender_slider = gr.Slider(label="Perceived Gender", minimum=-1, maximum=1, value=0, step=0.05)
|
@@ -339,8 +344,9 @@ with blocks:
|
|
339 |
ig_edit_choices = [pose_slider, smile_slider, gender_slider, age_slider, hair_slider]
|
340 |
|
341 |
with gr.TabItem("StyleCLIP Editing Options"):
|
342 |
-
gr.Markdown("
|
343 |
-
gr.Markdown("
|
|
|
344 |
|
345 |
src_text_styleclip = gr.Textbox(label="Source text")
|
346 |
tar_text_styleclip = gr.Textbox(label="Target text")
|
@@ -368,7 +374,7 @@ with blocks:
|
|
368 |
with gr.Row():
|
369 |
with gr.Column():
|
370 |
gr.Markdown("Warning: Videos generation requires the synthesis of hundreds of frames and is expected to take several minutes.")
|
371 |
-
gr.Markdown("To reduce queue times, we significantly reduced the number of video frames. Using more than 3 styles will further reduce the frames per style, leading to quicker transitions. For better control, we
|
372 |
with gr.Column():
|
373 |
vid_output = gr.outputs.Video(label="Output Video")
|
374 |
|
|
|
307 |
with blocks:
|
308 |
gr.Markdown("<h1><center>StyleGAN-NADA</center></h1>")
|
309 |
gr.Markdown(
|
310 |
+
"<h4 style='font-size: 110%;margin-top:.5em'>Inference demo for StyleGAN-NADA: CLIP-Guided Domain Adaptation of Image Generators (SIGGRAPH 2022).</h4>"
|
311 |
)
|
312 |
gr.Markdown(
|
313 |
+
"<h4 style='font-size: 110%;margin-top:.5em'>Usage</h4><div>Upload an image of your face, pick your desired output styles, and apply StyleGAN-based editing.</div>"
|
314 |
+
"<div>Choose the edit image tab to create static images in all chosen styles. Choose the video tab in order to interpolate between all chosen styles (But take it easy on the servers! We've limited video length, so if you add too many styles, they'll pass in the blink of an eye! π€)</div>"
|
315 |
+
)
|
316 |
+
gr.Markdown(
|
317 |
+
"For more information about the paper and code for training your own models (with examples OR text), please visit our <a href='https://stylegan-nada.github.io/' target='_blank'>Project Page</a> or the <a href='https://github.com/rinongal/StyleGAN-nada' target='_blank'>official repository</a>."
|
318 |
)
|
319 |
|
320 |
+
gr.Markdown("<h4 style='font-size: 110%;margin-top:.5em'>A note on social impact</h4><div>This model relies on StyleGAN and CLIP, both of which are prone to biases inherited from their training data and their architecture. These may include (but are not limited to) poor representation of minorities or the perpetution of societal biases, such as gender norms. Moreover, generative models can, and have been used to create deep fake imagery which may assist in the spread of propaganda. However, <a href='https://github.com/NVlabs/stylegan3-detector' target='_blank'>tools are available</a> for identifying StyleGAN generated imagery, and any 'realistic' results produced by this model should be easily identifiable through such tools.</div>")
|
|
|
321 |
|
322 |
with gr.Row():
|
323 |
input_img = gr.inputs.Image(type="filepath", label="Input image")
|
|
|
333 |
gr.Markdown("If multiple options are provided, they will be used randomly between images (or sequentially for a video), <u>not</u> together.")
|
334 |
gr.Markdown("Please note that some directions may be entangled. For example, hair length adjustments are likely to also modify the perceived gender.")
|
335 |
|
336 |
+
gr.Markdown("For more information about InterFaceGAN, please visit <a href='https://github.com/genforce/interfacegan' target='_blank'>the official repository</a>")
|
337 |
+
|
338 |
pose_slider = gr.Slider(label="Pose", minimum=-1, maximum=1, value=0, step=0.05)
|
339 |
smile_slider = gr.Slider(label="Smile", minimum=-1, maximum=1, value=0, step=0.05)
|
340 |
gender_slider = gr.Slider(label="Perceived Gender", minimum=-1, maximum=1, value=0, step=0.05)
|
|
|
344 |
ig_edit_choices = [pose_slider, smile_slider, gender_slider, age_slider, hair_slider]
|
345 |
|
346 |
with gr.TabItem("StyleCLIP Editing Options"):
|
347 |
+
gr.Markdown("Choose source and target descriptors, such as 'face with hair' to 'face with curly hair'")
|
348 |
+
gr.Markdown("Editing strength controls the magnitude of change. Disentanglement thresholds limits the number of channels the network can modify, reducing possible leak into other attributes. Setting the threshold too high may lead to no available channels. If you see an error, lower the threshold and try again.")
|
349 |
+
gr.Markdown("For more information about StyleCLIP, please visit <a href='https://github.com/orpatashnik/StyleCLIP' target='_blank'>the official repository</a>")
|
350 |
|
351 |
src_text_styleclip = gr.Textbox(label="Source text")
|
352 |
tar_text_styleclip = gr.Textbox(label="Target text")
|
|
|
374 |
with gr.Row():
|
375 |
with gr.Column():
|
376 |
gr.Markdown("Warning: Videos generation requires the synthesis of hundreds of frames and is expected to take several minutes.")
|
377 |
+
gr.Markdown("To reduce queue times, we significantly reduced the number of video frames. Using more than 3 styles will further reduce the frames per style, leading to quicker transitions. For better control, we recommend cloning the gradio app, adjusting <b>num_alphas</b> in <b>generate_videos.py</b>, and running the code locally.")
|
378 |
with gr.Column():
|
379 |
vid_output = gr.outputs.Video(label="Output Video")
|
380 |
|
generate_videos.py
CHANGED
@@ -74,7 +74,7 @@ def generate_frames(source_latent, target_latents, g_ema_list, output_dir):
|
|
74 |
|
75 |
np_target_latents = [target_latent.cpu().detach().numpy() for target_latent in target_latents]
|
76 |
|
77 |
-
num_alphas = min(10, 30 // len(target_latents))
|
78 |
|
79 |
alphas = np.linspace(0, 1, num=num_alphas)
|
80 |
|
|
|
74 |
|
75 |
np_target_latents = [target_latent.cpu().detach().numpy() for target_latent in target_latents]
|
76 |
|
77 |
+
num_alphas = 20 if code_is_s else min(10, 30 // len(target_latents))
|
78 |
|
79 |
alphas = np.linspace(0, 1, num=num_alphas)
|
80 |
|