mirror of
https://github.com/modelscope/DiffSynth-Studio.git
synced 2026-03-24 01:48:13 +00:00
unit test
This commit is contained in:
@@ -1,27 +1,38 @@
|
|||||||
import os, shutil, multiprocessing, time
|
import os, shutil, multiprocessing, time
|
||||||
|
|
||||||
|
|
||||||
def run_inference(script_path):
|
def script_is_processed(output_path, script):
|
||||||
output_path = os.path.join("data", script_path)
|
return os.path.exists(os.path.join(output_path, script))
|
||||||
for script in os.listdir(script_path):
|
|
||||||
if not script.endswith(".py"):
|
|
||||||
|
def filter_unprocessed_tasks(script_path, output_path):
|
||||||
|
tasks = []
|
||||||
|
for script in sorted(os.listdir(script_path)):
|
||||||
|
if not script.endswith(".sh") and not script.endswith(".py"):
|
||||||
continue
|
continue
|
||||||
|
if os.path.exists(os.path.join(output_path, script)):
|
||||||
|
continue
|
||||||
|
tasks.append(script)
|
||||||
|
return tasks
|
||||||
|
|
||||||
|
|
||||||
|
def run_inference(script_path, tasks):
|
||||||
|
output_path = os.path.join("data", script_path)
|
||||||
|
for script in tasks:
|
||||||
source_path = os.path.join(script_path, script)
|
source_path = os.path.join(script_path, script)
|
||||||
target_path = os.path.join(output_path, script)
|
target_path = os.path.join(output_path, script)
|
||||||
os.makedirs(target_path, exist_ok=True)
|
os.makedirs(target_path, exist_ok=True)
|
||||||
cmd = f"python {source_path} > {target_path}/log.txt 2>&1"
|
cmd = f"python {source_path} > {target_path}/log.txt 2>&1"
|
||||||
print(cmd)
|
print(cmd, flush=True)
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
for file_name in os.listdir("./"):
|
for file_name in os.listdir("./"):
|
||||||
if file_name.endswith(".jpg") or file_name.endswith(".png") or file_name.endswith(".mp4"):
|
if file_name.endswith(".jpg") or file_name.endswith(".png") or file_name.endswith(".mp4"):
|
||||||
shutil.move(file_name, os.path.join(target_path, file_name))
|
shutil.move(file_name, os.path.join(target_path, file_name))
|
||||||
|
|
||||||
|
|
||||||
def run_tasks_on_single_GPU(script_path, gpu_id, num_gpu):
|
def run_tasks_on_single_GPU(script_path, tasks, gpu_id, num_gpu):
|
||||||
output_path = os.path.join("data", script_path)
|
output_path = os.path.join("data", script_path)
|
||||||
for script_id, script in enumerate(sorted(os.listdir(script_path))):
|
for script_id, script in enumerate(tasks):
|
||||||
if not script.endswith(".sh") and not script.endswith(".py"):
|
|
||||||
continue
|
|
||||||
if script_id % num_gpu != gpu_id:
|
if script_id % num_gpu != gpu_id:
|
||||||
continue
|
continue
|
||||||
source_path = os.path.join(script_path, script)
|
source_path = os.path.join(script_path, script)
|
||||||
@@ -35,11 +46,9 @@ def run_tasks_on_single_GPU(script_path, gpu_id, num_gpu):
|
|||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
|
|
||||||
|
|
||||||
def run_train_multi_GPU(script_path):
|
def run_train_multi_GPU(script_path, tasks):
|
||||||
output_path = os.path.join("data", script_path)
|
output_path = os.path.join("data", script_path)
|
||||||
for script in os.listdir(script_path)[::-1]:
|
for script in tasks:
|
||||||
if not script.endswith(".sh"):
|
|
||||||
continue
|
|
||||||
source_path = os.path.join(script_path, script)
|
source_path = os.path.join(script_path, script)
|
||||||
target_path = os.path.join(output_path, script)
|
target_path = os.path.join(output_path, script)
|
||||||
os.makedirs(target_path, exist_ok=True)
|
os.makedirs(target_path, exist_ok=True)
|
||||||
@@ -79,5 +88,6 @@ if __name__ == "__main__":
|
|||||||
# run_train_single_GPU("examples/wanvideo/model_training/validate_lora")
|
# run_train_single_GPU("examples/wanvideo/model_training/validate_lora")
|
||||||
# move_files("video_", "data/output/validate_lora")
|
# move_files("video_", "data/output/validate_lora")
|
||||||
# run_train_multi_GPU("examples/wanvideo/model_training/full")
|
# run_train_multi_GPU("examples/wanvideo/model_training/full")
|
||||||
run_train_single_GPU("examples/wanvideo/model_training/validate_full")
|
# run_train_single_GPU("examples/wanvideo/model_training/validate_full")
|
||||||
move_files("video_", "data/output/validate_full")
|
# move_files("video_", "data/output/validate_full")
|
||||||
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user