Ejemplo n.º 1
0
def load_model():
    print('load model')
    device.set(device=DeviceId.GPU0)
    warnings.filterwarnings("ignore", category=UserWarning, message=".*?Your .*? set is empty.*?")

    model = get_image_colorizer(artistic=True)
    #model = get_image_colorizer(artistic=False)
    return model
Ejemplo n.º 2
0
def main():
    torch.backends.cudnn.benchmark=True
    #choices:  CPU, GPU0...GPU7
    device.set(device=DeviceId.GPU0)

    if not torch.cuda.is_available():
        print('GPU not available.')

    warnings.filterwarnings("ignore", category=UserWarning, message=".*?Your .*? set is empty.*?")
    colorizer = get_video_colorizer()

    source_url = 'https://www.reddit.com/r/nextfuckinglevel/comments/jyq24w/this_shot_from_the_movie_wings_1927_is_too_good/' #@param {type:"string"}
    render_factor = 21  #@param {type: "slider", min: 5, max: 40}
    watermarked = False #@param {type:"boolean"}
    if source_url is not None and source_url !='':
        video_path = colorizer.colorize_from_url(source_url, 'video.mp4', render_factor, watermarked=watermarked)
    else:
        print('Provide a video url and try again.')
Ejemplo n.º 3
0
from deoldify import device
from deoldify.device_id import DeviceId
device.set(device=DeviceId.GPU0)

from deoldify.visualize import *
plt.style.use('dark_background')
import warnings
warnings.filterwarnings("ignore",
                        category=UserWarning,
                        message=".*?Your .*? set is empty.*?")

colorizer = get_video_colorizer()


def colorize(video_path: str, render_factor: int = 21):
    # [5, 45]  21
    #NOTE:  Make source_url None to just read from file at ./video/source/[file_name] directly without modification
    source_url = 'https://twitter.com/silentmoviegifs/status/1116751583386034176'
    file_name = 'DogShy1926'
    file_name_ext = file_name + '.mp4'
    result_path = None

    if video_path is not None:
        result_path = colorizer.colorize_from_file_name(
            video_path, render_factor=render_factor)
    else:
        print("No video_path provided, defaulting to a example picture.")
        result_path = colorizer.colorize_from_url(source_url,
                                                  file_name_ext,
                                                  render_factor=render_factor)
Ejemplo n.º 4
0
                    help="input file path")
parser.add_argument("--out_file",
                    required=True,
                    type=str,
                    help="output file path")
parser.add_argument("--gpu",
                    required=True,
                    type=DeviceId.argparse,
                    choices=list(DeviceId))
parser.add_argument("--render_factor",
                    default=21,
                    type=int,
                    help="colorization render factor")

args = parser.parse_args()
in_file = args.in_file
out_file = args.out_file
gpu = args.gpu
render_factor = args.render_factor

device.set(device=gpu)

import fastai
from deoldify.visualize import *
from PIL import Image

print(f'Colorizing {in_file} to {out_file}')
colorizer = get_image_colorizer(artistic=False)
img = colorizer.get_transformed_image(in_file, render_factor=render_factor)
img.save(out_file)