python--TypeError: 'int' objectt is not interable

  目的:批量本地读图进行语义分割处理

  错误提示如图:

       搜索出来的结果一般是说Python在迭代的时候需要加 range 但是介于本文已经加了,所以问题不出现在这里.

     根据错误提示,发现是在 image.size这儿出问题的,所以应该要敏感地觉察出是输入图片有问题,而不是迭代有问题.

     可以用下面的输出指令查看图像格式.

    

print(image.dtype)

本文这里一开始输出是Unit8,和需求不匹配,所以需要改.(可见,Python读图和处理图时也是需要注意使用的图像类型的,感觉自己有点愚蠢了...)

image = Image.fromarray(coll[i],mode='RGB')

   具体的python中的图像格式问题,下一篇会转载查到的别人写的资料.

   所以最终的代码如下:   

#批量local读取图片  yyt
data_dir="/mnt/yyt/slam/colmap_data/ColMap/gerrard-hall/images"
str=data_dir + '/*.JPG'


def run_visualization(num,image):
  """Inferences DeepLab model and visualizes result.""" 
  try:
    #orignal_im = Image.open(path)
    #print('running deeplab on image %s...' % path)
    #num = np.str(i)
    orignal_im = image
    resized_im, seg_map = MODEL.run(orignal_im)
    vis_segmentation(num,resized_im, seg_map)
  except IOError:
    #print('Cannot retrieve image. Please check path: ' + path)
    print('Cannot retrieve image.')
    return


coll = io.ImageCollection(str)
#print(len(coll))
for i in range(len(coll)):
    IMAGE = Image.fromarray(coll[i],mode='RGB')
    num = np.str(i)
    run_visualization(num,IMAGE)

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值