Skip to content

Instantly share code, notes, and snippets.

@ckhung
Last active September 29, 2018 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckhung/b733e650ba689a7535c1141b86221c7b to your computer and use it in GitHub Desktop.
Save ckhung/b733e650ba689a7535c1141b86221c7b to your computer and use it in GitHub Desktop.
cpu-only Dockerfile for fast style transfer
# https://github.com/lengstrom/fast-style-transfer
FROM ckhung/fast-style-transfer:18C
# https://www.faqforge.com/linux/how-to-install-ffmpeg-on-ubuntu-14-04/
RUN add-apt-repository -y ppa:mc3man/trusty-media
RUN apt-get update
RUN apt-get -y dist-upgrade
RUN apt-get -y install ffmpeg
RUN pip install moviepy
# possible ramifications on proxmox:
# https://nikolaus.xyz/en/linux/2014/05/opensource-virtualisierung-ubuntu/openvzproxmox-container-rsyslog-problems-after-dist
CMD ["bash"]
# https://github.com/lengstrom/fast-style-transfer
FROM tensorflow/tensorflow:0.12.0
RUN pip install pillow==3.4.2
RUN apt -y update ; apt -y install git
RUN git clone https://github.com/lengstrom/fast-style-transfer /root/fst
WORKDIR /root/fst
CMD ["bash"]
from __future__ import print_function
from argparse import ArgumentParser
import sys
sys.path.insert(0, 'src')
import re, os, random, subprocess, evaluate, shutil
from utils import exists, list_files
import pdb
from warnings import warn
TMP_DIR = '.fns_frames_%s/' % random.randint(0,99999)
DEVICE = '/gpu:0'
BATCH_SIZE = 4
def build_parser():
parser = ArgumentParser()
parser.add_argument('--checkpoint', type=str,
dest='checkpoint', help='checkpoint directory or .ckpt file',
metavar='CHECKPOINT', required=True)
# parser.add_argument('--in-path', type=str,
# dest='in_path', help='in video path',
# metavar='IN_PATH', required=True)
parser.add_argument('--outdir', type=str, default='/tmp',
help='dirctory to save processed images/videos to',
metavar='OUT', required=True)
parser.add_argument('--tmp-dir', type=str, dest='tmp_dir',
help='tmp dir for processing', metavar='TMP_DIR',
default=TMP_DIR)
parser.add_argument('--device', type=str, dest='device',
help='device for eval. CPU discouraged. ex: \'/gpu:0\'',
metavar='DEVICE', default=DEVICE)
parser.add_argument('--batch-size', type=int,
dest='batch_size',help='batch size for eval. default 4.',
metavar='BATCH_SIZE', default=BATCH_SIZE)
parser.add_argument('--no-disk', type=bool, dest='no_disk',
help='Don\'t save intermediate files to disk. Default False',
metavar='NO_DISK', default=False)
parser.add_argument('ivfiles', nargs='*', type=str,
help='list of image and/or video files')
return parser
def check_opts(opts):
exists(opts.checkpoint)
exists(opts.out)
def main():
parser = build_parser()
opts = parser.parse_args()
for fullfn in opts.ivfiles:
m = re.search(r'([^/]*\.(jpe?g|png|gif|mp4))$', fullfn, re.IGNORECASE)
if not m:
warn('ignoring file with unknown suffix: ' + fullfn)
continue
fn0 = m.group(1)
print('processing ' + fullfn)
if (m.group(2) in ['mp4']):
evaluate.ffwd_video(fullfn, opts.outdir+'/'+fn0, opts.checkpoint, opts.device, opts.batch_size)
else:
evaluate.ffwd_to_img(fullfn, opts.outdir+'/'+fn0, opts.checkpoint, opts.device)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment