“系列”对象没有属性“调整大小”/“拆分”

问题描述

我正在做一个关于图像字幕的项目。

我们需要创建的第一个函数是 EncodeImage()。我们需要以某种方式对图像进行预处理并返回输出。功能是这样的。

我正在研究 Flicker8k 数据集。它有 40455 张图像,有 2 列,即图像和字幕。 1. `

import tensorflow.keras.preprocessing.image as tf_image
def encodeImage(img):
  img=img.resize((WIDTH,HEIGHT))
  x=tf_image.img_to_array(img)
  x=np.expand_dims(x,axis=0)
  x=preprocess_input(x)
  x=encode_model.predict(x)
  x=np.reshape(x,OUTPUT_DIM)
  return x

for i in range(data.shape[0]):
  image_path="/content/images"+data["image"][i]
  try:
    img=tf_image.load_img(image_path,target_size=(HEIGHT,WIDTH))
    
    encoded_images[data["image"][i].split(".")]=encodeImage(data["image"])
  except:
      print(i)
      remove_these.append(data["image"][i])

` 第二部分有一个 try 和 except 块。它排除了不支持的图像并将它们放入 remove_these 中。现在我所有的图像都被转移到 remove_these。如果我尝试通过运行代码来找到 remove_these 的长度和编码图像的长度 - len(remove_these),len(encoded_images),它会给我 - (40455,0) Am我做错了什么?问题出在哪里?

为了检查自己,我编写了单独的代码:

a[a]=data["image"][i].split(".")
en=encodeImage(data["image"])

第一个代码产生了错误 - 'Series' 对象没有属性 'split'。第二个代码产生了一个错误 - “'Series' 对象没有属性 'resize'。

请帮忙..

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...