4
4
import subprocess
5
5
import sys
6
6
import time
7
- from base64 import b64encode
8
7
from typing import Any
9
8
import gooey_gpu
10
9
33
32
)
34
33
from helpers .model_load import load_model , get_model_output_paths
35
34
from helpers .aesthetics import load_aesthetics_model
35
+ from helpers .prompts import Prompts
36
36
37
37
38
38
# @markdown **Path Setup**
@@ -89,16 +89,20 @@ class DeforumAnimArgs(BaseModel):
89
89
noise_schedule = "0: (0.02)" # @param {type:"string"}
90
90
strength_schedule = "0: (0.65)" # @param {type:"string"}
91
91
contrast_schedule = "0: (1.0)" # @param {type:"string"}
92
- hybrid_video_comp_alpha_schedule = "0:(1)" # @param {type:"string"}
93
- hybrid_video_comp_mask_blend_alpha_schedule = "0:(0.5)" # @param {type:"string"}
94
- hybrid_video_comp_mask_contrast_schedule = "0:(1)" # @param {type:"string"}
95
- hybrid_video_comp_mask_auto_contrast_cutoff_high_schedule = (
92
+ hybrid_comp_alpha_schedule = "0:(1)" # @param {type:"string"}
93
+ hybrid_comp_mask_blend_alpha_schedule = "0:(0.5)" # @param {type:"string"}
94
+ hybrid_comp_mask_contrast_schedule = "0:(1)" # @param {type:"string"}
95
+ hybrid_comp_mask_auto_contrast_cutoff_high_schedule = (
96
96
"0:(100)" # @param {type:"string"}
97
97
)
98
- hybrid_video_comp_mask_auto_contrast_cutoff_low_schedule = (
98
+ hybrid_comp_mask_auto_contrast_cutoff_low_schedule = (
99
99
"0:(0)" # @param {type:"string"}
100
100
)
101
101
102
+ # @markdown ####**Sampler Scheduling:**
103
+ enable_schedule_samplers = False # @param {type:"boolean"}
104
+ sampler_schedule = "0:('euler'),10:('dpm2'),20:('dpm2_ancestral'),30:('heun'),40:('euler'),50:('euler_ancestral'),60:('dpm_fast'),70:('dpm_adaptive'),80:('dpmpp_2s_a'),90:('dpmpp_2m')" # @param {type:"string"}
105
+
102
106
# @markdown ####**Unsharp mask (anti-blur) Parameters:**
103
107
kernel_schedule = "0: (5)" # @param {type:"string"}
104
108
sigma_schedule = "0: (1.0)" # @param {type:"string"}
@@ -108,6 +112,7 @@ class DeforumAnimArgs(BaseModel):
108
112
# @markdown ####**Coherence:**
109
113
color_coherence = "Match Frame 0 LAB" # @param ['None', 'Match Frame 0 HSV', 'Match Frame 0 LAB', 'Match Frame 0 RGB', 'Video Input'] {type:'string'}
110
114
color_coherence_video_every_N_frames = 1 # @param {type:"integer"}
115
+ color_force_grayscale = False # @param {type:"boolean"}
111
116
diffusion_cadence = "1" # @param ['1','2','3','4','5','6','7','8'] {type:'string'}
112
117
113
118
# @markdown ####**3D Depth Warping:**
@@ -130,25 +135,26 @@ class DeforumAnimArgs(BaseModel):
130
135
video_mask_path = "/content/video_in.mp4" # @param {type:"string"}
131
136
132
137
# @markdown ####**Hybrid Video for 2D/3D Animation Mode:**
133
- hybrid_video_generate_inputframes = False # @param {type:"boolean"}
134
- hybrid_video_use_first_frame_as_init_image = True # @param {type:"boolean"}
135
- hybrid_video_motion = (
136
- "None" # @param ['None','Optical Flow','Perspective','Affine']
138
+ hybrid_generate_inputframes = False # @param {type:"boolean"}
139
+ hybrid_use_first_frame_as_init_image = True # @param {type:"boolean"}
140
+ hybrid_motion = "None" # @param ['None','Optical Flow','Perspective','Affine']
141
+ hybrid_motion_use_prev_img = False # @param {type:"boolean"}
142
+ hybrid_flow_method = (
143
+ "DIS Medium" # @param ['DenseRLOF','DIS Medium','Farneback','SF']
137
144
)
138
- hybrid_video_flow_method = "Farneback" # @param ['Farneback','DenseRLOF','SF']
139
- hybrid_video_composite = False # @param {type:"boolean"}
140
- hybrid_video_comp_mask_type = (
145
+ hybrid_composite = False # @param {type:"boolean"}
146
+ hybrid_comp_mask_type = (
141
147
"None" # @param ['None', 'Depth', 'Video Depth', 'Blend', 'Difference']
142
148
)
143
- hybrid_video_comp_mask_inverse = False # @param {type:"boolean"}
144
- hybrid_video_comp_mask_equalize = "None" # @param ['None','Before','After','Both']
145
- hybrid_video_comp_mask_auto_contrast = False # @param {type:"boolean"}
146
- hybrid_video_comp_save_extra_frames = False # @param {type:"boolean"}
147
- hybrid_video_use_video_as_mse_image = False # @param {type:"boolean"}
149
+ hybrid_comp_mask_inverse = False # @param {type:"boolean"}
150
+ hybrid_comp_mask_equalize = "None" # @param ['None','Before','After','Both']
151
+ hybrid_comp_mask_auto_contrast = False # @param {type:"boolean"}
152
+ hybrid_comp_save_extra_frames = False # @param {type:"boolean"}
153
+ hybrid_use_video_as_mse_image = False # @param {type:"boolean"}
148
154
149
155
# @markdown ####**Interpolation:**
150
156
interpolate_key_frames = False # @param {type:"boolean"}
151
- interpolate_x_frames = 4 # @param {type:"number"}
157
+ interpolate_x_frames = 20 # @param {type:"number"}
152
158
153
159
# @markdown ####**Resume Animation:**
154
160
resume_from_timestring = False # @param {type:"boolean"}
@@ -157,6 +163,9 @@ class DeforumAnimArgs(BaseModel):
157
163
prompts = []
158
164
159
165
animation_prompts = {}
166
+ neg_animation_prompts = {}
167
+
168
+ args = {}
160
169
161
170
162
171
# @markdown **Load Settings**
@@ -195,7 +204,8 @@ class DeforumArgs:
195
204
196
205
# @markdown **Batch Settings**
197
206
n_batch = 1 # @param
198
- # batch_name = "StableFun" # @param {type:"string"}
207
+ n_samples = 1 # @param
208
+ batch_name = "StableFun" # @param {type:"string"}
199
209
filename_format = "{timestring}_{index}_{prompt}.png" # @param ["{timestring}_{index}_{seed}.png","{timestring}_{index}_{prompt}.png"]
200
210
seed_behavior = "iter" # @param ["iter","fixed","random","ladder","alternate"]
201
211
seed_iter_N = 1 # @param {type:'integer'}
@@ -204,11 +214,13 @@ class DeforumArgs:
204
214
205
215
# @markdown **Init Settings**
206
216
use_init = False # @param {type:"boolean"}
207
- strength = 0.1 # @param {type:"number"}
217
+ strength = 0.65 # @param {type:"number"}
208
218
strength_0_no_init = (
209
219
True # Set the strength to 0 automatically when no init image is used
210
220
)
211
221
init_image = "https://cdn.pixabay.com/photo/2022/07/30/13/10/green-longhorn-beetle-7353749_1280.jpg" # @param {type:"string"}
222
+ add_init_noise = False # @param {type:"boolean"}
223
+ init_noise = 0.01 # @param
212
224
# Whiter areas of the mask are areas that change more
213
225
use_mask = False # @param {type:"boolean"}
214
226
use_alpha_as_mask = False # use the alpha channel of the init image as the mask
@@ -262,12 +274,15 @@ class DeforumArgs:
262
274
# @markdown **Speed vs VRAM Settings**
263
275
cond_uncond_sync = True # @param {type:"boolean"}
264
276
265
- n_samples = 1 # doesnt do anything
266
277
precision = "autocast"
267
278
C = 4
268
279
f = 8
269
280
270
281
prompt = ""
282
+ cond_prompt = ""
283
+ cond_prompts = ""
284
+ uncond_prompt = ""
285
+ uncond_prompts = ""
271
286
timestring = ""
272
287
init_latent = None
273
288
init_sample = None
@@ -310,7 +325,7 @@ def run(root: Root, args: DeforumArgs, anim_args: DeforumAnimArgs):
310
325
if not args .use_init :
311
326
args .init_image = None
312
327
if args .sampler == "plms" and (args .use_init or anim_args .animation_mode != "None" ):
313
- print (f "Init images aren't supported with PLMS yet, switching to KLMS" )
328
+ print ("Init images aren't supported with PLMS yet, switching to KLMS" )
314
329
args .sampler = "klms"
315
330
if args .sampler != "ddim" :
316
331
args .ddim_eta = 0
@@ -324,15 +339,20 @@ def run(root: Root, args: DeforumArgs, anim_args: DeforumAnimArgs):
324
339
gc .collect ()
325
340
torch .cuda .empty_cache ()
326
341
342
+ # get prompts
343
+ cond , uncond = Prompts (
344
+ prompt = anim_args .animation_prompts , neg_prompt = anim_args .neg_animation_prompts
345
+ ).as_dict ()
346
+
327
347
# dispatch to appropriate renderer
328
348
if anim_args .animation_mode == "2D" or anim_args .animation_mode == "3D" :
329
- render_animation (args , anim_args , anim_args . animation_prompts , root )
349
+ render_animation (root , anim_args , args , cond , uncond )
330
350
elif anim_args .animation_mode == "Video Input" :
331
- render_input_video (args , anim_args , anim_args . animation_prompts , root )
351
+ render_input_video (root , anim_args , args , cond , uncond )
332
352
elif anim_args .animation_mode == "Interpolation" :
333
- render_interpolation (args , anim_args , anim_args . animation_prompts , root )
353
+ render_interpolation (root , anim_args , args , cond , uncond )
334
354
else :
335
- render_image_batch (args , anim_args . prompts , root )
355
+ render_image_batch (root , anim_args , args , cond , uncond )
336
356
337
357
338
358
def create_video (args : DeforumArgs , anim_args : DeforumAnimArgs ):
@@ -344,10 +364,10 @@ def create_video(args: DeforumArgs, anim_args: DeforumAnimArgs):
344
364
# mp4_path = "/content/drive/MyDrive/AI/StableDiffusion/2023-01/StableFun/20230101212135.mp4" # @param {type:"string"}
345
365
render_steps = False # @param {type: 'boolean'}
346
366
path_name_modifier = "x0_pred" # @param ["x0_pred","x"]
347
- make_gif = False
367
+ # make_gif = False # Currently unused
348
368
bitdepth_extension = "exr" if args .bit_depth_output == 32 else "png"
349
369
350
- if skip_video_for_run_all == True :
370
+ if skip_video_for_run_all :
351
371
print (
352
372
"Skipping video creation, uncheck skip_video_for_run_all if you want to run it"
353
373
)
0 commit comments