!apt-get update
!apt-get install sudo
!sudo apt-get update && apt-get install ffmpeg libsm6 libxext6 -y
!pip install modelscope==1.8.4
!pip install xformers==0.0.20
!pip install torch==2.0.1
!pip install open_clip_torch>=2.0.2
!pip install opencv-python-headless
!pip install opencv-python
!pip install einops>=0.4
!pip install rotary-embedding-torch
!pip install fairscale
!pip install scipy
!pip install imageio
!pip install pytorch-lightning
!pip install torchsde
!pip install easydict
from modelscope.pipelines import pipeline
from modelscope.outputs import OutputKeys
from modelscope import snapshot_download
#models
model_dir_1 = snapshot_download('damo/Image-to-Video', revision='v1.1.0')
model_dir_2 = snapshot_download('damo/Video-to-Video', revision='v1.1.0')
# set pipelines
pipe1 = pipeline(task='image-to-video', model=model_dir_1, model_revision='v1.1.0', device='cuda:0')
pipe2 = pipeline(task='video-to-video', model=model_dir_2, model_revision='v1.1.0', device='cuda:0')
# image to video
output_video_path = pipe1("input_1.png", output_video='./output_1.mp4')[OutputKeys.OUTPUT_VIDEO]
# video resolution
p_input = {'video_path': output_video_path}
new_output_video_path = pipe2(p_input, output_video='./output_1_HD.mp4')[OutputKeys.OUTPUT_VIDEO]
#text input
p_input = {'video_path': output_video_path, 'text': 'neon lights'}
# video resolution
new_output_video_path = pipe2(p_input, output_video='./output_2_HD.mp4')[OutputKeys.OUTPUT_VIDEO]