-
Notifications
You must be signed in to change notification settings - Fork 1
/
process_frames
executable file
·53 lines (37 loc) · 1.24 KB
/
process_frames
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
from os import listdir, fork, environ
from os.path import exists, isfile, join
from multiprocessing import Process
from time import sleep
import timeit
import numpy as np
#Number of GPU devices to use
GPU_COUNT=4
def f(thread,gpu):
environ["CUDA_VISIBLE_DEVICES"]="%d"%gpu
import deepdream as dd
import caffe
print "Use GPU %d"%gpu
caffe.set_mode_gpu()
videoframes = [ f for f in listdir('video_frames') if isfile(join('video_frames',f)) ]
np.random.seed(thread)
np.random.shuffle(videoframes)
for frame in videoframes:
if exists('processed_frames/'+frame):
print 'Skipping file already done'
else:
print frame
start_time = timeit.default_timer()
dd.deepdream(
img_name=join('video_frames',frame),
output_name=join('processed_frames',frame),
end='inception_4a/pool_proj',
iter_n=10,
octave_n=4,
dump_steps=False
)
elapsed = timeit.default_timer() - start_time
print 'took', elapsed
for i in range(GPU_COUNT*4):
Process(target=f,args=(i,i%GPU_COUNT,)).start()
sleep(0.1)