-
Notifications
You must be signed in to change notification settings - Fork 0
/
preprocess3o5.py
67 lines (56 loc) · 1.44 KB
/
preprocess3o5.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import cv2
import numpy as np
import os
from tqdm import tqdm
import pickle
data_dir = "E:/DL/facial-expression/augmented-images"
temp = 0
temp2 = 0
temp_list = []
for images in tqdm(os.listdir(data_dir)):
src = os.path.join(data_dir, images)
# name = str(temp) + ".png"
# dst = os.path.join(data_dir,name)
# temp+=1
im = src[41:]
im_break = im.split('_')
name = int(im_break[0])
temp_list.append(name)
if temp2 > 5:
temp2 = 0
if temp_list[temp] == name:
if temp2 == 0:
im_name = str(name) + "_1.png"
dst = os.path.join(data_dir, im_name)
os.rename(src, dst)
temp2 +=1
cond = bool(temp_list[temp] == temp_list[temp - 1])
if cond == False:
temp2 = 0
if temp2 == 1:
im_name = str(name) + "_2.png"
dst = os.path.join(data_dir, im_name)
os.rename(src, dst)
temp2 +=1
elif temp2 == 2:
im_name = str(name) + "_3.png"
dst = os.path.join(data_dir, im_name)
os.rename(src, dst)
temp2 +=1
elif temp2 == 3:
im_name = str(name) + "_4.png"
dst = os.path.join(data_dir, im_name)
os.rename(src, dst)
temp2 +=1
elif temp_list[temp] == temp_list[temp - 1]:
if temp2 == 4:
im_name = str(name) + "_5.png"
dst = os.path.join(data_dir, im_name)
os.rename(src, dst)
temp2 +=1
elif temp2 == 5:
im_name = str(name) + "_6.png"
dst = os.path.join(data_dir, im_name)
os.rename(src, dst)
temp2 +=1
temp += 1