Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python2
- import os, sys
- import os.path as op
- from PIL import Image
- from modules import data_wizard as dw
- from modules import dwarf as db
- from modules import imaginarium as img
- import pprint
- import random as rn
- import numpy as np
- def get_halfs(image):
- w, h = image.size
- im1 = image.crop([0, 0, w/2, h])
- im2 = image.crop([w - w/2, 0, w, h])
- return im1, im2
- def find_in_list(inp_list, target):
- for i, line in enumerate(inp_list):
- # print i, line
- if line == target:
- print target
- raw_input(line)
- return i
- return -1
- def get_path_linux(path):
- return '/'.join(path.split('/')[-2:])
- def get_path_win(path):
- return '/'.join(path.split('\\')[-2:])[:30]
- def subsample_idxs(src):
- idxs = np.arange(src.table.nrows)
- np.random.shuffle(idxs)
- return idxs[0:1000]
- if __name__ == '__main__':
- if len(sys.argv) < 3:
- dw.critisize_and_quit('Usage: <src> <dst>')
- src = sys.argv[1]
- dst = sys.argv[2]
- dw.is_path('Wrong path to src: "%s"' % src, src)
- src_base = db.DataBase(src)
- dst_base = db.DataBase(dst)
- ddict = {}
- n = src_base.table.nrows
- # for i in xrange(n):
- for i in subsample_idxs(src_base):
- cell = src_base.get_cell_dict(i)
- name = cell['name']
- # if name not in ddict:
- # ddict[name] = ''
- cell['image'] = src_base.read_image(i)
- dst_base.append_item(cell)
- dw.show_progress(i, n)
- print 'src size %d, dst size %d' % (src_base.table.nrows, dst_base.table.nrows)
- src_base.file_body.close()
- dst_base.file_body.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement