报错:Can't convert non-rectangular Python sequence to Tensor.
不知道怎么加语句让数组长度一致,有无大佬帮忙看看
代码是这样:
CLASS = ('Airport', 'Beach', 'Bridge', 'Commercial', 'Desert', 'Farmland', 'footballField', 'Forest', 'Industrial', 'Meadow', 'Mountain',
'Park', 'Parking', 'Pond', 'Port', 'railwayStation', 'Residential', 'River', 'Viaduct')
# 加载模型
model = load_model('model_UCMerced_LandUse.h5')
# 加载和预处理图像
path = 'D:/WHU-RS19/test/Park/Park_15.jpg'
img = image.load_img(path, target_size=(128, 128))
x = image.img_to_array(img) / 255.0
# 扩展维度以匹配模型输入
x = np.expand_dims(x, axis=0)
# 进行预测
classes1 = model.predict(x)
ind = np.argmax(classes1[lbk]0[rbk])
print("It is ", CLASS[lbk]ind[rbk])
不知道怎么加语句让数组长度一致,有无大佬帮忙看看
代码是这样:
CLASS = ('Airport', 'Beach', 'Bridge', 'Commercial', 'Desert', 'Farmland', 'footballField', 'Forest', 'Industrial', 'Meadow', 'Mountain',
'Park', 'Parking', 'Pond', 'Port', 'railwayStation', 'Residential', 'River', 'Viaduct')
# 加载模型
model = load_model('model_UCMerced_LandUse.h5')
# 加载和预处理图像
path = 'D:/WHU-RS19/test/Park/Park_15.jpg'
img = image.load_img(path, target_size=(128, 128))
x = image.img_to_array(img) / 255.0
# 扩展维度以匹配模型输入
x = np.expand_dims(x, axis=0)
# 进行预测
classes1 = model.predict(x)
ind = np.argmax(classes1[lbk]0[rbk])
print("It is ", CLASS[lbk]ind[rbk])