23 from .nodes.deforum_legacy_nodes import * 24 from .nodes.deforum_logic_nodes import * 25 try: 26 from .nodes.deforum_noise_nodes import AddCustomNoiseNode 27 except: 28 pass 29 try: 30 from .nodes.deforum_advnoise_node import AddAdvancedNoiseNode 31 except:
27 except: 28 pass 29 try: 30 from .nodes.deforum_advnoise_node import AddAdvancedNoiseNode 31 except: 32 pass 33 from .nodes.deforum_prompt_nodes import * 34 from .nodes.redirect_console_node import DeforumRedirectConsole 35 from .nodes.deforum_sampler_nodes import *
119 latent = latent 120 else: 121 latent = torch.from_numpy(np.array(init_image).astype(np.float32) / 255.0).unsqueeze(0) 122 latent = encode_latent(vae, latent, seed, subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w) 123 assert isinstance(latent, dict), \ 124 "Our Latents have to be in a dict format with the latent being the 'samples' value" 125 126 cond = [] 127
153 """ 154 if mode == 'fixed': 155 return [start_seed for _ in range(max_frames)] 156 elif mode == 'random': 157 return [random.randint(0, 2**32 - 1) for _ in range(max_frames)] 158 elif mode == 'ladder': 159 # Generate a ladder sequence where the sequence is repeated after reaching the max_frames 160 return [(start_seed + i // 2 * step if i % 2 == 0 else start_seed + (i // 2 + 1) * step) % (2**32) for i in range(max_frames)]
313 magnitude = np.sqrt((x2 - x) ** 2 + (y2 - y) ** 2) 314 315 # Only draw the line if it falls within the magnitude range 316 if min_magnitude <= magnitude <= max_magnitude: 317 if i % random.randint(100, 200) == 0: 318 b = int(bgr[y, x, 0]) 319 g = int(bgr[y, x, 1]) 320 r = int(bgr[y, x, 2])
69 # print( 70 # f"[deforum] Creating in-between {'' if cadence_flow is None else anim_args.optical_flow_cadence + ' optical flow '}cadence frame: {tween_frame_idx}; tween:{tween:0.2f};") 71 72 if depth_model is not None: 73 assert (self.turbo_next_image is not None) 74 self.depth = depth_model.predict(self.turbo_next_image, anim_args.midas_weight, root.half_precision) * depth_strength 75 76 if advance_prev:
308 "or": lambda a, b: a or b, 309 "not": lambda a: not a, 310 } 311 try: 312 return eval(expr, {"__builtins__": {}}, allowed_locals) 313 except NameError as e: 314 raise ValueError(f"Invalid expression: {e}") 315 except Exception as e:
154 # Copy the original vocabulary for restoration if needed 155 original_vocab = tokenizer.vocab.copy() 156 157 # Seed the random number generator for reproducibility 158 seeded_random = random.Random(seed) 159 160 # Create a list of (key, value) pairs, shuffle it, then convert it back to a dictionary 161 items = list(original_vocab.items())
247 self.vram_state = "high" 248 if "depth_model" in gs.deforum_models: 249 try: 250 gs.deforum_models["depth_model"].to("cpu") 251 except: 252 pass 253 del gs.deforum_models["depth_model"] 254 255 deforum_depth_algo = anim_args.depth_algorithm
194 operators = ['+', '-', '*', '/'] 195 globals = ['t', 'max_f', 's'] 196 parts = [] 197 198 for _ in range(random.randint(1, max_parts)): 199 func = random.choice(funcs) 200 operator = random.choice(operators) if parts else '' # No leading operator for the first part 201 global_var = random.choice(globals)
195 globals = ['t', 'max_f', 's'] 196 parts = [] 197 198 for _ in range(random.randint(1, max_parts)): 199 func = random.choice(funcs) 200 operator = random.choice(operators) if parts else '' # No leading operator for the first part 201 global_var = random.choice(globals) 202 if global_var == 'max_f':
196 parts = [] 197 198 for _ in range(random.randint(1, max_parts)): 199 func = random.choice(funcs) 200 operator = random.choice(operators) if parts else '' # No leading operator for the first part 201 global_var = random.choice(globals) 202 if global_var == 'max_f': 203 global_value = str(max_frames)
197 198 for _ in range(random.randint(1, max_parts)): 199 func = random.choice(funcs) 200 operator = random.choice(operators) if parts else '' # No leading operator for the first part 201 global_var = random.choice(globals) 202 if global_var == 'max_f': 203 global_value = str(max_frames) 204 else:
105 # Initialize or reset video capture 106 if self.cap is None or self.cap.get(cv2.CAP_PROP_POS_FRAMES) >= self.cap.get(cv2.CAP_PROP_FRAME_COUNT) or self.video_path != video_path or reset: 107 try: 108 self.cap.release() 109 except: 110 pass 111 self.cap = cv2.VideoCapture(video_path) 112 self.current_frame = -1 113 self.video_path = video_path
155 return "Invalid video file: {}".format(video) 156 return True 157 158 temp_dir = tempfile.mkdtemp() 159 hash_object = hashlib.md5(temp_dir.encode()) 160 hex_dig = hash_object.hexdigest() 161 endpoint = f"/tmp/{hex_dig}/{{filename}}" 162
157 158 temp_dir = tempfile.mkdtemp() 159 hash_object = hashlib.md5(temp_dir.encode()) 160 hex_dig = hash_object.hexdigest() 161 endpoint = f"/tmp/{hex_dig}/{{filename}}" 162 163 164 @server.PromptServer.instance.routes.get(endpoint)
330 self.audio_path = self.encode_audio_base64(audio, len(self.images), fps, 0) 331 332 ui_ret = {"counter":(len(self.images),), 333 "should_dump":(clear_cache,), 334 "frames":([f"/tmp/{self.hex_dig}/{os.path.basename(frame_path)}" for frame_path in self.images] if restore else [f"/tmp/{self.hex_dig}/{os.path.basename(frame_path)}" for frame_path in new_images]), 335 "fps":(fps,), 336 "audio":(f"/tmp/{self.hex_dig}/{self.audio_path}",)} 337 if waveform_image is not None:
330 self.audio_path = self.encode_audio_base64(audio, len(self.images), fps, 0) 331 332 ui_ret = {"counter":(len(self.images),), 333 "should_dump":(clear_cache,), 334 "frames":([f"/tmp/{self.hex_dig}/{os.path.basename(frame_path)}" for frame_path in self.images] if restore else [f"/tmp/{self.hex_dig}/{os.path.basename(frame_path)}" for frame_path in new_images]), 335 "fps":(fps,), 336 "audio":(f"/tmp/{self.hex_dig}/{self.audio_path}",)} 337 if waveform_image is not None:
332 ui_ret = {"counter":(len(self.images),), 333 "should_dump":(clear_cache,), 334 "frames":([f"/tmp/{self.hex_dig}/{os.path.basename(frame_path)}" for frame_path in self.images] if restore else [f"/tmp/{self.hex_dig}/{os.path.basename(frame_path)}" for frame_path in new_images]), 335 "fps":(fps,), 336 "audio":(f"/tmp/{self.hex_dig}/{self.audio_path}",)} 337 if waveform_image is not None: 338 ui_ret["waveform"] = (tensor_to_webp_base64(waveform_image),) 339 else:
54 server_instance = server.PromptServer.instance 55 sys.stdout = StreamToWebSocket(sys.stdout, server_instance, 'stdout') 56 sys.stderr = StreamToWebSocket(sys.stderr, server_instance, 'stderr') 57 console_redirected = True 58 except: 59 pass 60 else: 61 sys.stdout = stdout_backup 62 sys.stderr = stderr_backup
1 import os 2 import shutil 3 import sys 4 import subprocess 5 import threading 6 import locale 7 import traceback 8 import re
6 import locale 7 import traceback 8 import re 9 import os 10 import subprocess 11 import sys 12 import platform 13
33 34 35 def process_wrap(cmd_str, cwd=None, handler=None): 36 print(f"[Deforum] EXECUTE: {cmd_str} in '{cwd}'") 37 process = subprocess.Popen(cmd_str, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, bufsize=1) 38 39 if handler is None: 40 handler = handle_stream
59 global pip_list 60 61 if pip_list is None: 62 try: 63 result = subprocess.check_output([sys.executable, '-m', 'pip', 'list'], universal_newlines=True) 64 pip_list = set([line.split()[0].lower() for line in result.split('\n') if line.strip()]) 65 except subprocess.CalledProcessError as e: 66 print(f"[ComfyUI-Manager] Failed to retrieve the information of installed pip packages.")
121 """ 122 Runs a git command in the specified working directory and handles basic errors. 123 """ 124 try: 125 subprocess.run(command, shell=True, check=True, cwd=working_dir) 126 print(f"Successfully executed: {command} in {working_dir}") 127 except subprocess.CalledProcessError as e: 128 print(f"Error executing {command} in {working_dir}: {e}")
166 repo_dir = os.path.join(custom_nodes_path, repo_name) 167 clone_or_pull_repo(repo_url, repo_dir) 168 169 170 import subprocess 171 172 173 def install_packages():
174 # Install packages from requirements.txt 175 # subprocess.run(["pip", "install", "-r", "requirements.txt"], check=True) 176 177 # Force reinstall the deforum-studio package from Git 178 subprocess.run(["pip", "install", "--force-reinstall", "git+https://github.com/XmYx/deforum-studio.git"], 179 check=True) 180 181 182 def get_cuda_version():
174 # Install packages from requirements.txt 175 # subprocess.run(["pip", "install", "-r", "requirements.txt"], check=True) 176 177 # Force reinstall the deforum-studio package from Git 178 subprocess.run(["pip", "install", "--force-reinstall", "git+https://github.com/XmYx/deforum-studio.git"], 179 check=True) 180 181 182 def get_cuda_version():
180 181 182 def get_cuda_version(): 183 try: 184 cuda_version = subprocess.check_output(["nvcc", "--version"]).decode("utf-8") 185 for line in cuda_version.split('\n'): 186 if "release" in line: 187 return line.split('release')[1].split(',')[0].strip().replace('.', '')
180 181 182 def get_cuda_version(): 183 try: 184 cuda_version = subprocess.check_output(["nvcc", "--version"]).decode("utf-8") 185 for line in cuda_version.split('\n'): 186 if "release" in line: 187 return line.split('release')[1].split(',')[0].strip().replace('.', '')
213 os_name = platform.system() 214 wheel_name = construct_wheel_name(cuda_version, python_version, os_name) 215 url = f"https://github.com/chengzeyi/stable-fast/releases/download/v1.0.4/{wheel_name}" 216 print(f"Attempting to install: {wheel_name}") 217 subprocess.run([sys.executable, "-m", "pip", "install", url]) 218 219 220