-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from VideoVerses/feat/v2v
add: v2v-modelscope
- Loading branch information
Showing
7 changed files
with
99 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a cartoon dog is running in the forest. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os, sys | ||
import argparse | ||
sys.path.insert(0, os.getcwd()) | ||
|
||
from modelscope.models import Model | ||
from modelscope.pipelines import pipeline | ||
from modelscope.outputs import OutputKeys | ||
|
||
from scripts.inference_utils import load_inputs_v2v | ||
|
||
def get_parser(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--ckpt_path", type=str, default="checkpoints/Video-to-Video", help="Checkpoint path of the model") | ||
parser.add_argument("--input_dir", type=str, default=None, help="A input directory containing videos and prompts for video-to-video enhancement") | ||
parser.add_argument("--output_dir", type=str, default=None, help="Results saving directory") | ||
return parser | ||
|
||
# prepare arguments, model, pipeline. | ||
args = get_parser().parse_args() | ||
model = Model.from_pretrained(args.ckpt_path) | ||
pipe = pipeline(task="video-to-video", model=model, model_revision='v1.1.0', device='cuda:0') | ||
print(f"Successfully loaded model from {args.ckpt_path}") | ||
|
||
os.makedirs(args.output_dir, exist_ok=True) | ||
|
||
# load input prompts, video paths, video filenames | ||
prompt_list, video_filepaths, video_filenames = load_inputs_v2v(input_dir=args.input_dir) | ||
|
||
# video-to-video enhancement | ||
for i, (prompt, videofilepath, videofilename) in enumerate(zip(prompt_list, video_filepaths, video_filenames)): | ||
print(f"[{i}:03d] input path: {videofilepath}") | ||
print(f"[{i}:03d] input name: {videofilename}") | ||
print(f"[{i}:03d] prompt: {prompt}") | ||
p_input = { | ||
'video_path': videofilepath, | ||
'text': prompt | ||
} | ||
output_video_path = pipe(p_input, output_video=os.path.join(args.output_dir, videofilename))[OutputKeys.OUTPUT_VIDEO] | ||
print(f"Successfully processed {videofilename} and saved to {output_video_path}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
input_dir="inputs/v2v/001" | ||
current_time=$(date +%Y%m%d%H%M%S) | ||
output_dir="results/v2v/$current_time-v2v-modelscope-001" | ||
|
||
python3 scripts/inference_v2v_ms.py \ | ||
--input_dir $input_dir --output_dir $output_dir |