-
Notifications
You must be signed in to change notification settings - Fork 8
/
transfer_images.py
55 lines (32 loc) · 1.18 KB
/
transfer_images.py
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
from PIL import Image
from scipy.misc import imsave
import numpy
import glob, os
from multiprocessing import Pool
import cv2
folder_names = ['densepose', 'PNCC', '3dTex', 'face']
base_name = '/data1/cuiqingli/data/render_v5/unzipV3'
save_base_name = '/data1/cuiqingli/data/render_v5/denseposeV4_512'
def handler(folder_id):
dirname = os.path.join(base_name, str(folder_id))
save_dirname = os.path.join(save_base_name, str(folder_id))
for folder_name in folder_names:
folder_path = os.path.join(dirname, folder_name)
save_folder_path = os.path.join(save_dirname, folder_name)
for file in os.listdir(folder_path):
if file.endswith('.png'):
array = file.split(".")
image_id = array[0].split("_")[1]
image_id = int(image_id)
read_image = cv2.imread(os.path.join(folder_path, file))
print(read_image.shape)
down_px = 0
read_image = read_image[400-down_px :1120- down_px , 0:720]
read_image = cv2.resize(read_image, (512, 512))
save_image_path = os.path.join(save_folder_path, file)
print(save_image_path)
cv2.imwrite(save_image_path, read_image)
# handler(1)
lines = [i+1 for i in range(100)]
pool = Pool(42)
pool.map(handler, lines)