in question_generation_model.py [0:0]
def test_model_demo(self, test_image_url, model, beam_size):
response = requests.get(test_image_url)
test_image_content = Image.open(BytesIO(response.content))
test_image_content = test_image_content.resize((224, 224))
self.logger.debug('Extracting image feature')
try:
test_image_feature = self.datasets.extract_features_from_image(test_image_content)
except:
self.logger.error('Error in extracting image feature')
test_image_content = test_image_content.convert('RGB')
test_image_feature = self.datasets.extract_features_from_image(test_image_content)
self.logger.debug('Succesfully extracted image feature')
test_image_feature = test_image_feature.reshape((1, self.input_shape))
self.logger.info('Greedy search ---->')
candidates1 = self.greedy_search(test_image_feature, model)
self.logger.info('Simple beam search ---->')
output2, candidates2 = self.beam_search(test_image_feature, model, beam_size)
try:
self.logger.info('Diverse beam search ---->')
output3, candidates3 = self.diverse_beam_search(test_image_feature, model, beam_size, num_groups=2)
except:
self.logger.error('Failed to perform diverse beam search')
candidates3 = None
output3 = None
self.logger.info('Final Output: ---->%s', candidates1)
self.logger.info('\n')
return candidates1, candidates2, candidates3