forked from sunshineInmoon/Tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dir_to_dir.py
52 lines (44 loc) · 1.15 KB
/
dir_to_dir.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
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 29 10:38:36 2016
@author: Administrator
"""
#import cv2
import os
import numpy as np
import pickle
import shutil
def dis_cos(a,b):
sum0 = np.dot(a,b)
sum1 = np.sqrt(np.sum(np.power(a,2)))
sum2 = np.sqrt(np.sum(np.power(b,2)))
return sum0/(sum1*sum2)
caffe_root='C:/Users/Administrator/Desktop/'
import sys
sys.path.append(caffe_root+'python')
sys.path.append('D:/Anaconda/Lib/site-packages/')
sys.path.append('D:/Documents/Downloads/protobuf-2.5.0/protobuf-2.5.0/python/')
import caffe
'''
input_txt = 'E:/practical_face/LogPhoto/imageList.txt'
output_dir = 'E:/practical_face/result/Positive'
fr = open(input_txt,'r')
lines = fr.readlines()
num = 0
for line in lines:
path = line.strip().split(' ')[0]
lable = line.strip().split(' ')[1]
dir_name = output_dir + '/' + lable
if not os.path.exists(dir_name):
os.mkdir(dir_name)
num = 0
img = cv2.imread(path)
res = cv2.resize(img,(128,128))
gray = cv2.cvtColor(res,cv2.COLOR_BGR2GRAY)
output_path = "%s%s%d%s"%(dir_name,'/',num,'.bmp')
num += 1
cv2.imwrite(output_path,gray)
'''
'''
重新分类
'''