Colorize_video / app.py
Leo8613's picture
Update app.py
f55b4f4 verified
raw
history blame
725 Bytes
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)