我正在尝试从instagram头像中裁剪出面孔,方法是先检测面孔,然后调整图像大小。我正在读取所有存储在dataframe中的图像,然后创建一个numpy数组。然后,我运行了一个正面人脸检测器,它会返回一个对象,但当我调用该对象时,它会返回错误。我尝试只给出彩色图像作为输入,但这不起作用,也没有尝试和排除。代码如下:
df = pd.read_csv('/home/instaurls2.csv')
img_width, img_height = 139, 139
confidence = 0.8
#graph = K.get_session().graph
data1 = np.array([io.imread(row[1]) for row in df.itertuples()])
#print(data1)
detector = dlib.get_frontal_face_detector()
print (detector)
dets=detector(data1,1) # **error arrives here**
print (dets)
output=None
for i, d in enumerate(dets):
data1 = data1[d.top():d.bottom(), d.left():d.right()]
data1 = resize(data1, (img_width, img_height))
output = np.expand_dims(data1, axis=0)
print (output)
发布于 2019-08-19 20:13:07
默认情况下,Opencv将图像读取为BGR。
您可以使用cv2读取图像:
import cv2
cv2.imread(image_filepath)
https://stackoverflow.com/questions/48764485
复制