问题:snpe正常转化原始数据,报错
root@samsung-Samsung-DeskTop-System:/home/samsung/tools/snpe-1.40.0.2130# python /home/samsung/tools/snpe-1.40.0.2130/data_util.py -i /home/samsung/test/data_origin -o /home/samsung/test/ --height 32 --width 32
INFO: Creating SNPE raw data,height:32 width:32
create_raws main args:Namespace(dest='/home/samsung/test/data/cropped', height=32, img_folder='/home/samsung/test/data', resize_type='bilinear', width=32)
Converting images for inception v3 network.
Scaling to square: /home/samsung/test/data
/home/samsung/test/data/0007.jpg
__resize_square_to_jpg w:32 h:32
Traceback (most recent call last):
File "/home/samsung/tools/snpe-1.40.0.2130/scripts/create_raws.py", line 140, in <module>
exit(main())
File "/home/samsung/tools/snpe-1.40.0.2130/scripts/create_raws.py", line 137, in main
convert_img(src,dest,args.height,args.width,resize_type)
File "/home/samsung/tools/snpe-1.40.0.2130/scripts/create_raws.py", line 105, in convert_img
__resize_square_to_jpg(src_image,dest_image,width,height,resize_type)
File "/home/samsung/tools/snpe-1.40.0.2130/scripts/create_raws.py", line 88, in __resize_square_to_jpg
dst_img = img.resize((w, h), Image.BILINEAR)
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 1528, in resize
self.load()
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 1963, in load
self.im = self.im.crop(self.__crop)
TypeError: integer argument expected, got float
INFO: Creating image list data files
No results with /home/samsung/test/data/cropped/*.raw
No results with /home/samsung/test/data/cropped/*.raw
错误的意思是:
期望得到的是整数,而你却得到了浮点数
原因:
create_raws.py代码中有这么一句:
crop_coord = (
(width - short_dim) / 2,
(height - short_dim) / 2,
(width + short_dim) / 2,
(height + short_dim) / 2
)
python3中的整除应该是//,而不是/
所以代码中的/得到的是浮点数,所以会出错
将/改成//就不会报错了!