mirror of
https://github.com/guoyww/AnimateDiff.git
synced 2025-12-24 04:09:36 +01:00
webui added w/demo & docs
This commit is contained in:
41
utils.py
Normal file
41
utils.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import copy
|
||||
import os
|
||||
import subprocess as sub
|
||||
import gdown
|
||||
import yaml
|
||||
|
||||
def yaml_to_dict(filename):
|
||||
with open(filename, 'r') as file:
|
||||
data = yaml.safe_load(file)
|
||||
return copy.deepcopy(data)
|
||||
|
||||
def dict_to_yaml(data, filename):
|
||||
with open(filename, 'w') as file:
|
||||
yaml.safe_dump(data, file)
|
||||
|
||||
def download_from_drive_gdown(file_id, output_path):
|
||||
url = f'https://drive.google.com/uc?id={file_id}'
|
||||
gdown.download(url, output_path, quiet=False)
|
||||
|
||||
def verbose_print(text):
|
||||
print(f"{text}")
|
||||
|
||||
def create_dirs(arb_path):
|
||||
if not os.path.exists(arb_path):
|
||||
os.makedirs(arb_path)
|
||||
|
||||
def make_all_dirs(list_of_paths):
|
||||
for path in list_of_paths:
|
||||
create_dirs(path)
|
||||
|
||||
def execute(cmd):
|
||||
popen = sub.Popen(cmd, stdout=sub.PIPE, universal_newlines=True)
|
||||
for stdout_line in iter(popen.stdout.readline, ""):
|
||||
yield stdout_line
|
||||
popen.stdout.close()
|
||||
return_code = popen.wait()
|
||||
if return_code:
|
||||
raise sub.CalledProcessError(return_code, cmd)
|
||||
|
||||
def is_windows():
|
||||
return os.name == 'nt'
|
||||
Reference in New Issue
Block a user