use return json format instead of return locals() in args.py

pull/732/head
hithereai 2023-05-20 13:24:55 +03:00
parent b853305a71
commit 3e2e55559f
1 changed files with 215 additions and 207 deletions

View File

@ -12,225 +12,233 @@ from .deforum_controlnet import controlnet_component_names
from .general_utils import get_os, substitute_placeholders from .general_utils import get_os, substitute_placeholders
def RootArgs(): def RootArgs():
device = sh.device return {
models_path = ph.models_path + '/Deforum' "device": sh.device,
half_precision = not cmd_opts.no_half "models_path": ph.models_path + '/Deforum',
mask_preset_names = ['everywhere', 'video_mask'] "half_precision": not cmd_opts.no_half,
frames_cache = [] "mask_preset_names": ['everywhere', 'video_mask'],
raw_batch_name = None "frames_cache": [],
raw_seed = None "raw_batch_name": None,
initial_info = None "raw_seed": None,
first_frame = None "initial_info": None,
animation_prompts = None "first_frame": None,
current_user_os = get_os() "animation_prompts": None,
tmp_deforum_run_duplicated_folder = os.path.join(tempfile.gettempdir(), 'tmp_run_deforum') "current_user_os": get_os(),
return locals() "tmp_deforum_run_duplicated_folder": os.path.join(tempfile.gettempdir(), 'tmp_run_deforum')
}
def CoreArgs(): # TODO: change or do something with this ugliness def CoreArgs(): # TODO: change or do something with this ugliness
subseed = -1 return {
subseed_strength = 0 "subseed": -1,
timestring = "" "subseed_strength": 0,
init_sample = None "timestring": "",
noise_mask = None "init_sample": None,
seed_internal = 0 "noise_mask": None,
return locals() "seed_internal": 0
}
def DeforumAnimArgs(): def DeforumAnimArgs():
animation_mode = '2D' # ['None', '2D', '3D', 'Video Input', 'Interpolation'] return {
max_frames = 120 "animation_mode": '2D', # ['None', '2D', '3D', 'Video Input', 'Interpolation']
border = 'replicate' # ['wrap', 'replicate'] "max_frames": 120,
angle = "0:(0)" "border": 'replicate', # ['wrap', 'replicate']
zoom = "0:(1.0025+0.002*sin(1.25*3.14*t/30))" "angle": "0:(0)",
translation_x = "0:(0)" "zoom": "0:(1.0025+0.002*sin(1.25*3.14*t/30))",
translation_y = "0:(0)" "translation_x": "0:(0)",
translation_z = "0:(1.75)" "translation_y": "0:(0)",
transform_center_x = "0:(0.5)" "translation_z": "0:(1.75)",
transform_center_y = "0:(0.5)" "transform_center_x": "0:(0.5)",
rotation_3d_x = "0:(0)" "transform_center_y": "0:(0.5)",
rotation_3d_y = "0:(0)" "rotation_3d_x": "0:(0)",
rotation_3d_z = "0:(0)" "rotation_3d_y": "0:(0)",
enable_perspective_flip = False "rotation_3d_z": "0:(0)",
perspective_flip_theta = "0:(0)" "enable_perspective_flip": False,
perspective_flip_phi = "0:(0)" "perspective_flip_theta": "0:(0)",
perspective_flip_gamma = "0:(0)" "perspective_flip_phi": "0:(0)",
perspective_flip_fv = "0:(53)" "perspective_flip_gamma": "0:(0)",
noise_schedule = "0: (0.065)" "perspective_flip_fv": "0:(53)",
strength_schedule = "0: (0.65)" "noise_schedule": "0: (0.065)",
contrast_schedule = "0: (1.0)" "strength_schedule": "0: (0.65)",
cfg_scale_schedule = "0: (7)" "contrast_schedule": "0: (1.0)",
enable_steps_scheduling = False "cfg_scale_schedule": "0: (7)",
steps_schedule = "0: (25)" "enable_steps_scheduling": False,
fov_schedule = "0: (70)" "steps_schedule": "0: (25)",
aspect_ratio_schedule = "0: (1)" "fov_schedule": "0: (70)",
aspect_ratio_use_old_formula = False "aspect_ratio_schedule": "0: (1)",
near_schedule = "0: (200)" "aspect_ratio_use_old_formula": False,
far_schedule = "0: (10000)" "near_schedule": "0: (200)",
seed_schedule = '0:(s), 1:(-1), "max_f-2":(-1), "max_f-1":(s)' "far_schedule": "0: (10000)",
pix2pix_img_cfg_scale_schedule = "0:(1.5)" "seed_schedule": '0:(s), 1:(-1), "max_f-2":(-1), "max_f-1":(s)',
enable_subseed_scheduling = False "pix2pix_img_cfg_scale_schedule": "0:(1.5)",
subseed_schedule = "0:(1)" "enable_subseed_scheduling": False,
subseed_strength_schedule = "0:(0)" "subseed_schedule": "0:(1)",
enable_sampler_scheduling = False # Sampler Scheduling "subseed_strength_schedule": "0:(0)",
sampler_schedule = '0: ("Euler a")' "enable_sampler_scheduling": False, # Sampler Scheduling
use_noise_mask = False # Composable mask scheduling "sampler_schedule": '0: ("Euler a")',
mask_schedule = '0: ("{video_mask}")' "use_noise_mask": False, # Composable mask scheduling
noise_mask_schedule = '0: ("{video_mask}")' "mask_schedule": '0: ("{video_mask}")',
enable_checkpoint_scheduling = False # Checkpoint Scheduling "noise_mask_schedule": '0: ("{video_mask}")',
checkpoint_schedule = '0: ("model1.ckpt"), 100: ("model2.safetensors")' "enable_checkpoint_scheduling": False, # Checkpoint Scheduling
enable_clipskip_scheduling = False # CLIP skip Scheduling "checkpoint_schedule": '0: ("model1.ckpt"), 100: ("model2.safetensors")',
clipskip_schedule = '0: (2)' "enable_clipskip_scheduling": False, # CLIP skip Scheduling
enable_noise_multiplier_scheduling = True # Noise Multiplier Scheduling "clipskip_schedule": '0: (2)',
noise_multiplier_schedule = '0: (1.05)' "enable_noise_multiplier_scheduling": True, # Noise Multiplier Scheduling
# resume params "noise_multiplier_schedule": '0: (1.05)',
resume_from_timestring = False # resume params
resume_timestring = "20230129210106" "resume_from_timestring": False,
# DDIM AND Ancestral ETA scheds "resume_timestring": "20230129210106",
enable_ddim_eta_scheduling = False # DDIM AND Ancestral ETA scheds
ddim_eta_schedule = "0:(0)" "enable_ddim_eta_scheduling": False,
enable_ancestral_eta_scheduling = False "ddim_eta_schedule": "0:(0)",
ancestral_eta_schedule = "0:(1)" "enable_ancestral_eta_scheduling": False,
# Anti-blur "ancestral_eta_schedule": "0:(1)",
amount_schedule = "0: (0.1)" # Anti-blur
kernel_schedule = "0: (5)" "amount_schedule": "0: (0.1)",
sigma_schedule = "0: (1.0)" "kernel_schedule": "0: (5)",
threshold_schedule = "0: (0.0)" "sigma_schedule": "0: (1.0)",
# Coherence "threshold_schedule": "0: (0.0)",
color_coherence = 'LAB' # ['None', 'HSV', 'LAB', 'RGB', 'Video Input', 'Image'] # Coherence
color_coherence_image_path = "" "color_coherence": 'LAB', # ['None', 'HSV', 'LAB', 'RGB', 'Video Input', 'Image']
color_coherence_video_every_N_frames = 1 "color_coherence_image_path": "",
color_force_grayscale = False "color_coherence_video_every_N_frames": 1,
legacy_colormatch = False "color_force_grayscale": False,
diffusion_cadence = '2' # ['1','2','3','4','5','6','7','8'] "legacy_colormatch": False,
optical_flow_cadence = 'None' # ['None', 'RAFT','DIS Medium', 'DIS Fine', 'Farneback'] "diffusion_cadence": '2', # ['1','2','3','4','5','6','7','8']
cadence_flow_factor_schedule = "0: (1)" "optical_flow_cadence": 'None', # ['None', 'RAFT','DIS Medium', 'DIS Fine', 'Farneback']
optical_flow_redo_generation = 'None' # ['None', 'RAFT', 'DIS Medium', 'DIS Fine', 'Farneback'] "cadence_flow_factor_schedule": "0: (1)",
redo_flow_factor_schedule = "0: (1)" "optical_flow_redo_generation": 'None', # ['None', 'RAFT', 'DIS Medium', 'DIS Fine', 'Farneback']
diffusion_redo = '0' "redo_flow_factor_schedule": "0: (1)",
# **Noise settings:** "diffusion_redo": '0',
noise_type = 'perlin' # ['uniform', 'perlin'] # **Noise settings:**
# Perlin params "noise_type": 'perlin', # ['uniform', 'perlin']
perlin_w = 8 # Perlin params
perlin_h = 8 "perlin_w": 8,
perlin_octaves = 4 "perlin_h": 8,
perlin_persistence = 0.5 "perlin_octaves": 4,
# **3D Depth Warping:** "perlin_persistence": 0.5,
use_depth_warping = True # **3D Depth Warping:**
depth_algorithm = 'Midas-3-Hybrid' # ['Midas+AdaBins (old)','Zoe+AdaBins (old)', 'Midas-3-Hybrid','Midas-3.1-BeitLarge', 'AdaBins', 'Zoe', 'Leres'] Midas-3.1-BeitLarge is temporarily removed 04-05-23 until fixed "use_depth_warping": True,
midas_weight = 0.2 # midas/ zoe weight - only relevant in old/ legacy depth_algorithm modes. see above ^ "depth_algorithm": 'Midas-3-Hybrid',
padding_mode = 'border' # ['border', 'reflection', 'zeros'] # ['Midas+AdaBins (old)','Zoe+AdaBins (old)', 'Midas-3-Hybrid','Midas-3.1-BeitLarge', 'AdaBins', 'Zoe', 'Leres'] Midas-3.1-BeitLarge is temporarily removed 04-05-23 until fixed
sampling_mode = 'bicubic' # ['bicubic', 'bilinear', 'nearest'] "midas_weight": 0.2, # midas/ zoe weight - only relevant in old/ legacy depth_algorithm modes. see above ^
save_depth_maps = False "padding_mode": 'border', # ['border', 'reflection', 'zeros']
# **Video Input:** "sampling_mode": 'bicubic', # ['bicubic', 'bilinear', 'nearest']
video_init_path = 'https://deforum.github.io/a1/V1.mp4' "save_depth_maps": False,
extract_nth_frame = 1 # **Video Input:**
extract_from_frame = 0 "video_init_path": 'https://deforum.github.io/a1/V1.mp4',
extract_to_frame = -1 # minus 1 for unlimited frames "extract_nth_frame": 1,
overwrite_extracted_frames = True "extract_from_frame": 0,
use_mask_video = False "extract_to_frame": -1, # minus 1 for unlimited frames
video_mask_path = 'https://deforum.github.io/a1/VM1.mp4' "overwrite_extracted_frames": True,
# **Hybrid Video for 2D/3D Animation Mode:** "use_mask_video": False,
hybrid_comp_alpha_schedule = "0:(0.5)" "video_mask_path": 'https://deforum.github.io/a1/VM1.mp4',
hybrid_comp_mask_blend_alpha_schedule = "0:(0.5)" # **Hybrid Video for 2D/3D Animation Mode:**
hybrid_comp_mask_contrast_schedule = "0:(1)" "hybrid_comp_alpha_schedule": "0:(0.5)",
hybrid_comp_mask_auto_contrast_cutoff_high_schedule = "0:(100)" "hybrid_comp_mask_blend_alpha_schedule": "0:(0.5)",
hybrid_comp_mask_auto_contrast_cutoff_low_schedule = "0:(0)" "hybrid_comp_mask_contrast_schedule": "0:(1)",
hybrid_flow_factor_schedule = "0:(1)" "hybrid_comp_mask_auto_contrast_cutoff_high_schedule": "0:(100)",
hybrid_generate_inputframes = False "hybrid_comp_mask_auto_contrast_cutoff_low_schedule": "0:(0)",
hybrid_generate_human_masks = "None" # ['None','PNGs','Video', 'Both'] "hybrid_flow_factor_schedule": "0:(1)",
hybrid_use_first_frame_as_init_image = True "hybrid_generate_inputframes": False,
hybrid_motion = "None" # ['None','Optical Flow','Perspective','Affine'] "hybrid_generate_human_masks": "None", # ['None','PNGs','Video', 'Both']
hybrid_motion_use_prev_img = False "hybrid_use_first_frame_as_init_image": True,
hybrid_flow_consistency = False "hybrid_motion": "None", # ['None','Optical Flow','Perspective','Affine']
hybrid_consistency_blur = 2 "hybrid_motion_use_prev_img": False,
hybrid_flow_method = "RAFT" # ['RAFT', 'DIS Medium', 'DIS Fine', 'Farneback'] "hybrid_flow_consistency": False,
hybrid_composite = 'None' # ['None', 'Normal', 'Before Motion', 'After Generation'] "hybrid_consistency_blur": 2,
hybrid_use_init_image = False "hybrid_flow_method": "RAFT", # ['RAFT', 'DIS Medium', 'DIS Fine', 'Farneback']
hybrid_comp_mask_type = "None" # ['None', 'Depth', 'Video Depth', 'Blend', 'Difference'] "hybrid_composite": 'None', # ['None', 'Normal', 'Before Motion', 'After Generation']
hybrid_comp_mask_inverse = False "hybrid_use_init_image": False,
hybrid_comp_mask_equalize = "None" # ['None','Before','After','Both'] "hybrid_comp_mask_type": "None", # ['None', 'Depth', 'Video Depth', 'Blend', 'Difference']
hybrid_comp_mask_auto_contrast = False "hybrid_comp_mask_inverse": False,
hybrid_comp_save_extra_frames = False "hybrid_comp_mask_equalize": "None", # ['None','Before','After','Both']
return locals() "hybrid_comp_mask_auto_contrast": False,
"hybrid_comp_save_extra_frames": False
}
def DeforumArgs(): def DeforumArgs():
# set default image size and make sure to resize to multiples of 64 if needed return {
W, H = map(lambda x: x - x % 64, (512, 512)) "W": 512, # width
# whether to show gradio's info section for all params in the ui. it's a realtime toggle "H": 512, # height
show_info_on_ui = True # whether to show gradio's info section for all params in the ui. it's a realtime toggle
# **Webui stuff** "show_info_on_ui": True,
tiling = False # **Webui stuff**
restore_faces = False "tiling": False,
seed_enable_extras = False "restore_faces": False,
seed_resize_from_w = 0 "seed_enable_extras": False,
seed_resize_from_h = 0 "seed_resize_from_w": 0,
# **Sampling Settings** "seed_resize_from_h": 0,
seed = -1 # # **Sampling Settings**
sampler = 'euler_ancestral' # ["klms","dpm2","dpm2_ancestral","heun","euler","euler_ancestral","plms", "ddim"] "seed": -1,
steps = 25 # "sampler": 'euler_ancestral',
# **Batch Settings** "steps": 25,
batch_name = "Deforum_{timestring}" # **Batch Settings**
seed_behavior = "iter" # ["iter","fixed","random","ladder","alternate","schedule"] "batch_name": "Deforum_{timestring}",
seed_iter_N = 1 "seed_behavior": "iter",
# **Init Settings** "seed_iter_N": 1,
use_init = False # **Init Settings**
strength = 0.8 "use_init": False,
strength_0_no_init = True # Set the strength to 0 automatically when no init image is used "strength": 0.8,
init_image = "https://deforum.github.io/a1/I1.png" "strength_0_no_init": True,
# Whiter areas of the mask are areas that change more "init_image": "https://deforum.github.io/a1/I1.png",
use_mask = False # Whiter areas of the mask are areas that change more
use_alpha_as_mask = False # use the alpha channel of the init image as the mask "use_mask": False,
mask_file = "https://deforum.github.io/a1/M1.jpg" "use_alpha_as_mask": False,
invert_mask = False "mask_file": "https://deforum.github.io/a1/M1.jpg",
# Adjust mask image, 1.0 is no adjustment. Should be positive numbers. "invert_mask": False,
mask_contrast_adjust = 1.0 # Adjust mask image, 1.0 is no adjustment. Should be positive numbers.
mask_brightness_adjust = 1.0 "mask_contrast_adjust": 1.0,
# Overlay the masked image at the end of the generation so it does not get degraded by encoding and decoding "mask_brightness_adjust": 1.0,
overlay_mask = True # Overlay the masked image at the end of the generation so it does not get degraded by encoding and decoding
# Blur edges of final overlay mask, if used. Minimum = 0 (no blur) "overlay_mask": True,
mask_overlay_blur = 4 # Blur edges of final overlay mask, if used. Minimum = 0 (no blur)
fill = 1 # MASKARGSEXPANSION Todo : Rename and convert to same formatting as used in img2img masked content "mask_overlay_blur": 4,
full_res_mask = True "fill": 1,
full_res_mask_padding = 4 "full_res_mask": True,
reroll_blank_frames = 'reroll' # reroll, interrupt, or ignore "full_res_mask_padding": 4,
reroll_patience = 10 "reroll_blank_frames": 'reroll',
return locals() "reroll_patience": 10
}
def LoopArgs(): def LoopArgs():
use_looper = False return {
init_images = get_guided_imgs_default_json() "use_looper": False,
image_strength_schedule = "0:(0.75)" "init_images": get_guided_imgs_default_json(),
blendFactorMax = "0:(0.35)" "image_strength_schedule": "0:(0.75)",
blendFactorSlope = "0:(0.25)" "blendFactorMax": "0:(0.35)",
tweening_frames_schedule = "0:(20)" "blendFactorSlope": "0:(0.25)",
color_correction_factor = "0:(0.075)" "tweening_frames_schedule": "0:(20)",
return locals() "color_correction_factor": "0:(0.075)"
}
def ParseqArgs(): def ParseqArgs():
parseq_manifest = None return {
parseq_use_deltas = True "parseq_manifest": None,
return locals() "parseq_use_deltas": True
}
def DeforumOutputArgs(): def DeforumOutputArgs():
skip_video_creation = False return {
fps = 15 "skip_video_creation": False,
make_gif = False "fps": 15,
delete_imgs = False # True will delete all imgs after a successful mp4 creation "make_gif": False,
image_path = "C:/SD/20230124234916_%09d.png" "delete_imgs": False, # True will delete all imgs after a successful mp4 creation
add_soundtrack = 'None' # ["File","Init Video"] "image_path": "C:/SD/20230124234916_%09d.png",
soundtrack_path = "https://deforum.github.io/a1/A1.mp3" "add_soundtrack": 'None', # ["File","Init Video"]
# End-Run upscaling "soundtrack_path": "https://deforum.github.io/a1/A1.mp3",
r_upscale_video = False # End-Run upscaling
r_upscale_factor = 'x2' # ['2x', 'x3', 'x4'] "r_upscale_video": False,
r_upscale_model = 'realesr-animevideov3' # 'realesr-animevideov3' (default of realesrgan engine, does 2-4x), the rest do only 4x: 'realesrgan-x4plus', 'realesrgan-x4plus-anime' "r_upscale_factor": 'x2', # ['2x', 'x3', 'x4'],
r_upscale_keep_imgs = True "r_upscale_model": 'realesr-animevideov3', # 'realesr-animevideov3' (default of realesrgan engine, does 2-4x), the rest do only 4x:'realesrgan-x4plus', 'realesrgan-x4plus-anime'
store_frames_in_ram = False "r_upscale_keep_imgs": True,
# **Interpolate Video Settings** "store_frames_in_ram": False,
frame_interpolation_engine = "None" # ["None", "RIFE v4.6", "FILM"] # **Interpolate Video Settings**
frame_interpolation_x_amount = 2 # [2 to 1000 depends on the engine] "frame_interpolation_engine": "None", # ["None", "RIFE v4.6", "FILM"]
frame_interpolation_slow_mo_enabled = False "frame_interpolation_x_amount": 2, # [2 to 1000 depends on the engine]
frame_interpolation_slow_mo_amount = 2 # [2 to 10] "frame_interpolation_slow_mo_enabled": False,
frame_interpolation_keep_imgs = False "frame_interpolation_slow_mo_amount": 2, # [2 to 10]
return locals() "frame_interpolation_keep_imgs": False
}
def get_component_names(): def get_component_names():
return ['override_settings_with_file', 'custom_settings_file', *DeforumAnimArgs().keys(), 'animation_prompts', 'animation_prompts_positive', 'animation_prompts_negative', return ['override_settings_with_file', 'custom_settings_file', *DeforumAnimArgs().keys(), 'animation_prompts', 'animation_prompts_positive', 'animation_prompts_negative',