# Copyright (C) 2023 Deforum LLC
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
# Contact the authors: https://deforum.github.io/
def get_samplers_list():
return {
'euler a': 'Euler a',
'euler': 'Euler',
'lms': 'LMS',
'heun': 'Heun',
'dpm2': 'DPM2',
'dpm2 a': 'DPM2 a',
'dpm++ 2s a': 'DPM++ 2S a',
'dpm++ 2m': 'DPM++ 2M',
'dpm++ sde': 'DPM++ SDE',
'dpm fast': 'DPM fast',
'dpm adaptive': 'DPM adaptive',
'lms karras': 'LMS Karras',
'dpm2 karras': 'DPM2 Karras',
'dpm2 a karras': 'DPM2 a Karras',
'dpm++ 2s a karras': 'DPM++ 2S a Karras',
'dpm++ 2m karras': 'DPM++ 2M Karras',
'dpm++ sde karras': 'DPM++ SDE Karras'
}
def DeforumAnimPrompts():
return r"""{
"0": "tiny cute bunny, vibrant diffraction, highly detailed, intricate, ultra hd, sharp photo, crepuscular rays, in focus",
"30": "anthropomorphic clean cat, surrounded by fractals, epic angle and pose, symmetrical, 3d, depth of field",
"60": "a beautiful coconut --neg photo, realistic",
"90": "a beautiful durian, award winning photography"
}
"""
# Guided images defaults
def get_guided_imgs_default_json():
return '''{
"0": "https://deforum.github.io/a1/Gi1.png",
"max_f/4-5": "https://deforum.github.io/a1/Gi2.png",
"max_f/2-10": "https://deforum.github.io/a1/Gi3.png",
"3*max_f/4-15": "https://deforum.github.io/a1/Gi4.jpg",
"max_f-20": "https://deforum.github.io/a1/Gi1.png"
}'''
def get_hybrid_info_html():
return """
Hybrid Video Compositing in 2D/3D Mode
by reallybigname
- Composite video with previous frame init image in 2D or 3D animation_mode (not for Video Input mode)
- Uses your Init settings for video_init_path, extract_nth_frame, overwrite_extracted_frames
- In Keyframes tab, you can also set color_coherence = 'Video Input'
- color_coherence_video_every_N_frames lets you only match every N frames
- Color coherence may be used with hybrid composite off, to just use video color.
- Hybrid motion may be used with hybrid composite off, to just use video motion.
Hybrid Video Schedules
- The alpha schedule controls overall alpha for video mix, whether using a composite mask or not.
- The hybrid_comp_mask_blend_alpha_schedule only affects the 'Blend' hybrid_comp_mask_type.
- Mask contrast schedule is from 0-255. Normal is 1. Affects all masks.
- Autocontrast low/high cutoff schedules 0-100. Low 0 High 100 is full range.
(hybrid_comp_mask_auto_contrast must be enabled)
Click Here for more info/ a Guide.
"""
def get_composable_masks_info_html():
return """
- To enable, check use_mask in the Init tab
- Supports boolean operations: (! - negation, & - and, | - or, ^ - xor, \ - difference, () - nested operations)
- default variables: in \{\}, like \{init_mask\}, \{video_mask\}, \{everywhere\}
- masks from files: in [], like [mask1.png]
- description-based: word masks in <>, like <apple>, <hair>
"""
def get_parseq_info_html():
return """
Use a Parseq manifest for your animation (leave blank to ignore).
Fields managed in your Parseq manifest override the values and schedules set in other parts of this UI. You can select which values to override by using the "Managed Fields" section in Parseq.
"""
def get_prompts_info_html():
return """
- Please always keep values in math functions above 0.
- There is *no* Batch mode like in vanilla deforum. Please Use the txt2img tab for that.
- For negative prompts, please write your positive prompt, then --neg ugly, text, assymetric, or any other negative tokens of your choice. OR:
- Use the negative_prompts field to automatically append all words as a negative prompt. *Don't* add --neg in the negative_prompts field!
- Prompts are stored in JSON format. If you've got an error, check it in a JSON Validator
"""
def get_guided_imgs_info_html():
return """
You can use this as a guided image tool or as a looper depending on your settings in the keyframe images field.
Set the keyframes and the images that you want to show up.
Note: the number of frames between each keyframe should be greater than the tweening frames.
Prerequisites and Important Info:
- This mode works ONLY with 2D/3D animation modes. Interpolation and Video Input modes aren't supported.
- Init tab's strength slider should be greater than 0. Recommended value (.65 - .80).
- 'seed_behavior' will be forcibly set to 'schedule'.
Looping recommendations:
- seed_schedule should start and end on the same seed.
Example: seed_schedule could use 0:(5), 1:(-1), 219:(-1), 220:(5)
- The 1st and last keyframe images should match.
- Set your total number of keyframes to be 21 more than the last inserted keyframe image.
Example: Default args should use 221 as the total keyframes.
- Prompts are stored in JSON format. If you've got an error, check it in the validator,
like here
The Guided images mode exposes the following variables for the prompts and the schedules:
- s is the initial seed for the whole video generation.
- max_f is the length of the video, in frames.
Example: seed_schedule could use 0:(s), 1:(-1), "max_f-2":(-1), "max_f-1":(s)
- t is the current frame number.
Example: strength_schedule could use 0:(0.25 * cos((72 / 60 * 3.141 * (t + 0) / 30))**13 + 0.7) to make alternating changes each 30 frames
"""
def get_main_info_html():
return """
Made by deforum.github.io, port for AUTOMATIC1111's webui maintained by Deforum LLC.
FOR HELP CLICK HERE
- The code for this extension: here.
- Join the official Deforum Discord to share your creations and suggestions.
- Official Deforum Wiki: here.
- Anime-inclined great guide (by FizzleDorf) with lots of examples: here.
- For advanced keyframing with Math functions, see here.
- Alternatively, use sd-parseq as a UI to define your animation schedules (see the Parseq section in the Init tab).
- framesync.xyz is also a good option, it makes compact math formulae for Deforum keyframes by selecting various waveforms.
- The other site allows for making keyframes using interactive splines and Bezier curves (select Disco output format).
- If you want to use Width/Height which are not multiples of 64, please change noise_type to 'Uniform', in Keyframes --> Noise.
If you liked this extension, please give it a star on GitHub! 😊
"""
def get_frame_interpolation_info_html():
return """
Use RIFE / FILM Frame Interpolation to smooth out, slow-mo (or both) any video.
Supported engines:
Important notes:
- Frame Interpolation will *not* run if any of the following are enabled: 'Store frames in ram' / 'Skip video for run all'.
- Audio (if provided) will *not* be transferred to the interpolated video if Slow-Mo is enabled.
- 'add_soundtrack' and 'soundtrack_path' aren't being honoured in "Interpolate an existing video" mode. Original vid audio will be used instead with the same slow-mo rules above.
- In "Interpolate existing pics" mode, FPS is determined *only* by output FPS slider. Audio will be added if requested even with slow-mo "enabled", as it does *nothing* in this mode.
"""
def get_frames_to_video_info_html():
return """
Important Notes:
- Enter relative to webui folder or Full-Absolute path, and make sure it ends with something like this: '20230124234916_%09d.png', just replace 20230124234916 with your batch ID. The %09d is important, don't forget it!
- In the filename, '%09d' represents the 9 counting numbers, For '20230124234916_000000001.png', use '20230124234916_%09d.png'
- If non-deforum frames, use the correct number of counting digits. For files like 'bunnies-0000.jpg', you'd use 'bunnies-%04d.jpg'
"""
def get_leres_info_html():
return 'Note that LeReS has a Non-Commercial license. Use it only for fun/personal use.'
def get_gradio_html(section_name):
if section_name.lower() == 'hybrid_video':
return get_hybrid_info_html()
elif section_name.lower() == 'composable_masks':
return get_composable_masks_info_html()
elif section_name.lower() == 'parseq':
return get_parseq_info_html()
elif section_name.lower() == 'prompts':
return get_prompts_info_html()
elif section_name.lower() == 'guided_imgs':
return get_guided_imgs_info_html()
elif section_name.lower() == 'main':
return get_main_info_html()
elif section_name.lower() == 'frame_interpolation':
return get_frame_interpolation_info_html()
elif section_name.lower() == 'frames_to_video':
return get_frames_to_video_info_html()
elif section_name.lower() == 'leres':
return get_leres_info_html()
else:
return ""
mask_fill_choices = ['fill', 'original', 'latent noise', 'latent nothing']