snpe python转化raw_data数据报TypeError: integer argument expected, got float

问题: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中的整除应该是//,而不是/

所以代码中的/得到的是浮点数,所以会出错

将/改成//就不会报错了!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值