本文主要是介绍Kaggle-Facial Keypoints Detection:原始数据保存为图片,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
python version: Python 3.6.4
如题,将原始数据“training.csv”中的图片数据保存成文件,直接上代码:
import numpy as np
import pandas as pd
from PIL import Image
training = pd.read_csv("training.csv")
training['Image'] = training['Image'].apply(lambda im: np.fromstring(im, sep=' '))
for index, row in training.iterrows():
img_data = row['Image'].astype('uint8').reshape(96,96)
img = Image.fromarray(img_data)
img.save('./Images/' + str(10000000+index) + ".jpg", 'jpeg')
效果如下图:
这篇关于Kaggle-Facial Keypoints Detection:原始数据保存为图片的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!