Я работаю с "Automati c Генератор титров изображений, используя CNN, LSTM & Res Net
def get_prediction():
orig_image, image = next(iter(data_loader))
plt.imshow(np.squeeze(orig_image))
plt.title('Sample Image')
plt.show()
image = image.to(device)
features = encoder(image).unsqueeze(1)
output = decoder.sample(features)
sentence = clean_sentence(output)
print(sentence)
get_prediction()
**THIS ABOVE CODE IS WORKING PERFECTLY TO DISPLAYING RANDOM IMAGES WITH THEIR CAPTIONS**
Здесь я использовал этот код ниже, чтобы сгенерировать заголовок для новое изображение, но получаю неправильный результат
def new_prediction(image_name):
image = Image.open(image_name)
plt.imshow(np.squeeze(image))
plt.title('Sample Image')
plt.show()
image = transforms.ToTensor()(image).unsqueeze_(0)
image = image.to(device)
features = encoder(image).unsqueeze(1)
output = decoder.sample(features)
sentence = clean_sentence(output)
print(sentence)
new_prediction("image.jpg")
Пожалуйста, помогите мне создать точную подпись для нового входного изображения