0

I am trying to run code that is not in github but is giving error (IndentationError: allowed an indent block)

from imageai.Prediction import ImagePrediction
import os
execution_path = os.getcwd()
prediction = ImagePrediction()
prediction.setModelTypeAsResNet()
prediction.setModelPath( execution_path + "\resnet50_weights_tf_dim_ordering_tf_kernels.h5")
prediction.loadModel()$


predictions, percentage_probabilities = prediction.predictImage("C:\Users\MyUser\Downloads\1.jpg", 
result_count=5)
for index in range(len(predictions)):
print(predictions[index] , " : " , percentage_probabilities[index])

File "C:\Users...", line 12 print(predictions[index] , " : " , percentage_probabilities[index]) ^ IndentationError: expected an indented block [Finished in 0.1s with exit code 1]

1 Answers1

0

You just need to indent the final line of code. Indentation matters in python, it's required syntax in for loops.

from imageai.Prediction import ImagePrediction
import os
execution_path = os.getcwd()
prediction = ImagePrediction()
prediction.setModelTypeAsResNet()
prediction.setModelPath( execution_path + "\resnet50_weights_tf_dim_ordering_tf_kernels.h5")
prediction.loadModel()$


predictions, percentage_probabilities = prediction.predictImage("C:\Users\MyUser\Downloads\1.jpg", 
result_count=5)
for index in range(len(predictions)):
    print(predictions[index] , " : " , percentage_probabilities[index])
Kyle Safran
  • 463
  • 3
  • 8