-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NameError: name 'image_array' is not defined #681
Comments
First Tip: Learn the simple Error codes from python Second Tip : Add these Lines to your code
1 Question, or more like a prediction. You are new to python programming? If so, you should start learning the main error messages from python, like a "Type Error" or a "Syntax Error" or the "Name Error". Btw a quick google search can help much faster, an easier. This comment should not stop you from programming, it is just that these Libraries are so easy to use that even a person which new to this topic is able to use them, which leads to so many issue calls that are easily solved by a quick google search. So if you have any other question, you can ask me, but for you to improve yourself it would be better to try to solve the issue by your self with a quick search, and I am for 100% sure the "Name Error" has been solved somewhere on sites like Stack Overflow or other coding websites. Maybe not the exact same one, but those Errors always have the "same" cause and solution. |
ok thanks. I'm pretty much an absolute beginner. i'm trying to just use the image prediction on a personal project i know basics of running python but the code scrambles my mind. where exactly in the code should i put the code you suggested? |
This is the modified version, just coy it, and it should run it. |
If you want, I can try to explain to you what the code makes. |
i tried the code and got this " execution_path = os.getcwd() i feel like im missing something obvious sometimes lol |
what python version you running ?? |
3.7.6 |
Is there a space in front of the line ? |
the code is the one you replied with. from imageai.Classification import ImageClassification image_array = np.assaray(Image.open("PATH_TO_THE_IMAGE_YOU_WANT_TO_PREDICT_ON") prediction = ImageClassification() predictions, probabilities = prediction.classifyImage(image_array, result_count=5 , input_type="array" ) |
@ovladuk
|
If you hover over the yellow bar on the left side it would show you like I said before that I missed a closing bracket |
this is the fixed code |
thanks for the help i kind of gave up with that code cause for some reason the model just didn't want to work. must be corrupt somehow. |
scratch the last post i sent. i got it to predict the image but it doesn't predict the other images in the folder. |
By the way, you can just delete a comment, and please stop comment each comment again if it is not necessary thy. ** here is the Solution for your Problem***
|
sorry i was just getting frustrated because it wasnt working. ive tried multiple different versions of code with no success. thanks it worked! i had to change "assaray" to "asarray" but it worked after that. thanks for your help! |
im getting "NameError: name 'image_array' is not defined" error from this code. can anyone help?
from imageai.Classification import ImageClassification
import os
execution_path = os.getcwd()
prediction = ImageClassification()
prediction.setModelTypeAsResNet50()
prediction.setModelPath(os.path.join(execution_path, "resnet50_imagenet_tf.2.0.h5"))
prediction.loadModel()
predictions, probabilities = prediction.classifyImage(image_array, result_count=5 , input_type="array" )
for eachPrediction, eachProbability in zip(predictions, probabilities):
print(eachPrediction , " : " , eachProbability)
The text was updated successfully, but these errors were encountered: