python - (sendex face_recognition) cv2 中的照片整形问题。将用作人脸识别的输入
问题描述
我正在关注 senddex 人脸识别视频。我正在使用自己的图片来训练尺寸非常大的模型,因此我在cv2.reshape()
此处的帮助下将图片的尺寸更改为 256x256,这是我用于调整大小的代码。我为 10 张照片做了 10 次,你可以使用循环。
import cv2
#paste the path where you have face recognition file
#for me it is '/home/Desktop/ml/face_reco'
path = str(input("paste you file path here: "))
IMG_SIZE = 256
# convert to array
img_array = cv2.imread(path)
new_array = cv2.resize(img_array, (IMG_SIZE, IMG_SIZE))
#save the resized pic with some new name
cv2.imwrite('/home/Desktop/ml/face_reco/known_faces/vardhan/new.png',new_array)
当我使用这些新调整大小的图片作为模型的输入时,它会引发错误list index out of range
,因为在encoding
senddex代码的第 38 行中数组是空的,我不知道为什么编码数组对于新图片是空的,而对于原始图片不是空的图片。
解决方案
推荐阅读
- python - Pandas 内爆 Dataframe,其值由 char 分隔
- angular - 如何避免在 Angular 中使用 *ngFor?
- c# - Is there a better way to implement multithreading?
- python - How to provide a password over ssh using python script?
- c++ - How to get all (non-disabled) user SIDs via Windows API?
- node.js - 如何在进一步行动之前等待续集结果?
- python - Is there an effcient way to perform search query in django?
- lightgbm - 提升 LightGBM 的超参数:“goss”是否使用“gbdt”作为基础模型?
- android - 选项菜单显示缓慢
- javascript - react-native 如何在“触摸”后更改 FlatList 中呈现的项目样式?