File size: 725 Bytes
f55b4f4
 
56d08ee
f55b4f4
 
 
 
56d08ee
f55b4f4
 
 
3cdf272
f55b4f4
3cdf272
f55b4f4
 
091614b
f55b4f4
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from deoldify.visualize import get_video_colorizer
import torch

# Load the video colorization model
def load_video_model():
    model_path = 'ColorizeVideo_gen.pth'  # Path to the model in the root directory
    video_colorizer = get_video_colorizer()

    # Load the model's state from the .pth file
    state = torch.load(model_path, map_location=torch.device('cpu'))  # Adjust if using GPU
    video_colorizer.learn.model.load_state_dict(state)

    return video_colorizer

# Example usage of the video colorizer
video_colorizer = load_video_model()

# You can now use the colorizer to colorize a video
video_path = 'your_video.mp4'
colorized_video = video_colorizer.colorize_from_file_name(video_path, render_factor=35)