ImageAI
ImageAI copied to clipboard
accuracy 100%????
I trained in custom models,but who i put a pic on it(bus.png) it tell me car : 100.0 bus : 0.0 person : 0.0 why?
Hi,
- How long did you train your network
- What was the last loss and accuracy you have seen before training?
- Have you run the normal imageai prediction code or some custom code?
If you can answer me those Questions I am able and willing to help you other wise it is like asking a another person "what is that?" Without giving the location of the object they are asking for.
Hopefully you not disturbe by my explanation why I need at least those 3 information in order to help you
Best regards @ekesdf
1.I use cpu ,about 8 hours. 2.lost:0.0648 acc: 0.9722 3.I fallow the file to train my model. i use resnet at first, no matter what i do ,the result is same as above.i find a people have a same question at github. so i chang my model(DenseNet121), Now,the result seems like better but not very good ,maybe i have not finish my training. My english is poor,hope you can understand my meaning.Thank you.
Well CPU is not the best way to train but your loss and acc: look very good
can you send me the code you use for this thy
I have simmilar problem. I train custom model and use it.
Always one class 100% remained 0 even if i use images from training folder form other class.
accuracy 0.979584 lat loss i dont remeber
I have simmilar problem. I train custom model and use it. Always one class 100% remained 0 even if i use images from training folder form other class.
![]()
accuracy 0.979584 lat loss i dont remeber
you can try to not use resnet,i use desnet121 and solved my question
still dont work to me. other classes has more than 0, but always one classes is favorited by model.
chang you .h5 file ?
------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年8月30日(星期一) 中午1:30 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [OlafenwaMoses/ImageAI] accuracy 100%???? (#692)
still dont work to me. other classes has more than 0, but always one classes is favorited by model.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
of course.
Ok i probably find. 60% of my photos is one class. when I equalized the division of photos in the training set, it started to work better.
congratulations!
------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年8月30日(星期一) 下午3:04 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [OlafenwaMoses/ImageAI] accuracy 100%???? (#692)
Ok i probably find. 60% of my photos is one class. when I equalized the division of photos in the training set, it started to work better.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
oh i mistake. If model isn't train well that better, but when i trained to: "Epoch 66/66 62/62 [==============================] - 916s 15s/step - loss: 0.1928 - accuracy: 0.9258 - val_loss: 0.3220 - val_accuracy: 0.8750" still have problem
Hi every one I tested this sample FirstCustomPrediction.py and model downloaded from this site but get wrong result, 100.00 for 1 object and remains 0.
from imageai.Classification.Custom import CustomImageClassification import os
execution_path = os.getcwd()
prediction = CustomImageClassification() prediction.setModelTypeAsResNet50() prediction.setModelPath(os.path.join(execution_path, "idenprof_resnet_ex-056_acc-0.993062.h5")) prediction.setJsonPath(os.path.join(execution_path, "idenprof.json")) prediction.loadModel(num_objects=10)
predictions, probabilities = prediction.classifyImage(os.path.join(execution_path, "4.jpg"), result_count=5)
for eachPrediction, eachProbability in zip(predictions, probabilities): print(eachPrediction , " : " , eachProbability)
result: d:\Code\FirstCustomPrediction.py 2021-09-15 11:29:28.048896: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found 2021-09-15 11:29:28.048896: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. 2021-09-15 11:29:29.619986: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set 2021-09-15 11:29:29.620986: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found 2021-09-15 11:29:29.620986: W tensorflow/stream_executor/cuda/cuda_driver.cc:326] failed call to cuInit: UNKNOWN ERROR (303) 2021-09-15 11:29:29.625986: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: tr0y-PC 2021-09-15 11:29:29.626986: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: tr0y-PC 2021-09-15 11:29:29.628987: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2021-09-15 11:29:29.630987: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set 2021-09-15 11:29:31.115072: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:116] None of the MLIR optimization passes are enabled (registered 2) farmer : 100.0 waiter : 0.0 police : 0.0 pilot : 0.0 mechanic : 0.0
please help thank you
ONE: farmer : 100.0 waiter : 0.0 police : 0.0 pilot : 0.0 mechanic : 0.0 prediction.loadModel(num_objects=10) may be five?
TWO: may be you can change your models,like desnet
ONE: farmer : 100.0 waiter : 0.0 police : 0.0 pilot : 0.0 mechanic : 0.0 prediction.loadModel(num_objects=10) may be five?
TWO: may be you can change your models,like desnet
Hi, It is the code from this site, there are 10 objects in that model, but it just print out 5 results, that is ok
ONE: farmer : 100.0 waiter : 0.0 police : 0.0 pilot : 0.0 mechanic : 0.0 prediction.loadModel(num_objects=10) may be five?
TWO: may be you can change your models,like desnet
Hi, It is the code from this site, there are 10 objects in that model, but it just print out 5 results, that is ok
I thought I was the only one. I took the example code and images(idenprof) from the imageAi documentation. I tried first training 200 images and 200 test image (3 objects engineer,farmer,doctor) after 100 epochs, the system always is wrong guessing 100 percent engineer for doctor or farmer. Tried 200 training and 40 testing same. Tried the 900 images with 200 training for 30 epochs same error. I will test it for 200 epochs and update if anything changed.
problem noticed: accuracy reaches 100 percent and val accuracy 80 but it never guess right. Maybe overfitting? but it is the example given in docs
ONE: farmer : 100.0 waiter : 0.0 police : 0.0 pilot : 0.0 mechanic : 0.0 prediction.loadModel(num_objects=10) may be five?
TWO: may be you can change your models,like desnet
Hi, It is the code from this site, there are 10 objects in that model, but it just print out 5 results, that is ok
I thought I was the only one. I took the example code and images(idenprof) from the imageAi documentation. I tried first training 200 images and 200 test image (3 objects engineer,farmer,doctor) after 100 epochs, the system always is wrong guessing 100 percent engineer for doctor or farmer. Tried 200 training and 40 testing same. Tried the 900 images with 200 training for 30 epochs same error. I will test it for 200 epochs and update if anything changed.
problem noticed: accuracy reaches 100 percent and val accuracy 80 but it never guess right. Maybe overfitting? but it is the example given in docs
have you solved the issue having the same one on a custom dataset?
Hi, I could not solve issue. how ever I used Yolo3 for Object training and detection model and It works. Thank you and best resgards Nhien
Vào 3:15, Th 7, 23 thg 10, 2021 AnzeVersnik @.***> đã viết:
ONE: farmer : 100.0 waiter : 0.0 police : 0.0 pilot : 0.0 mechanic : 0.0 prediction.loadModel(num_objects=10) may be five?
TWO: may be you can change your models,like desnet
Hi, It is the code from this site, there are 10 objects in that model, but it just print out 5 results, that is ok
I thought I was the only one. I took the example code and images(idenprof) from the imageAi documentation. I tried first training 200 images and 200 test image (3 objects engineer,farmer,doctor) after 100 epochs, the system always is wrong guessing 100 percent engineer for doctor or farmer. Tried 200 training and 40 testing same. Tried the 900 images with 200 training for 30 epochs same error. I will test it for 200 epochs and update if anything changed.
problem noticed: accuracy reaches 100 percent and val accuracy 80 but it never guess right. Maybe overfitting? but it is the example given in docs
have you solved the issue having the same one on a custom dataset?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/OlafenwaMoses/ImageAI/issues/692#issuecomment-949932611, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIIXQMIEKS6C6MHD3UPPOILUIHA6NANCNFSM5CNSPFBA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Having the same issue, this REALLY needs to be adressed, or reverted to the old imageai version that was using tensorflow 1.15.
I directly compared ImageAI with TF 2.4 to ImageAI with TF 1.15. I used exactly the same dataset, the same model (resnet), but the results with TF 2.4 are 100% accuracy for always the same class. There is a huge bug in this version.
Not even the samples in the documentation work any more.
Downgrade to an older ImageAI Version with TF 1.15 for example, and everything works as intended.
@OlafenwaMoses Please have a look at that, or revert the changes in the git so that atleast the samples work again.
Fellow AI enthusiasts, I may have pinpointed the issue. This is my first time posting to Github, so apologies if there is a better way to show the issue in the code.
If you take a look in __init__.py
for the custom classification class (Python3.x\Lib\site-packages\imageai\Classification\Custom), in the loadModel function of class CustomImageClassification
the (self.__modelType == "resnet50")
case has an extra line of code that the other models do not:
elif(self.__modelType == "resnet50"):
try:
model = tf.keras.applications.ResNet50(input_shape=(self.__input_image_size, self.__input_image_size, 3), weights=None, classes = num_objects )
model.load_weights(self.modelPath) #<~~~~ extra code
self.__model_collection.append(model)
self.__modelLoaded = True
I'm not sure what it does, but being that every other model just uses .append
it seemed strange. I commented it out and the RestNet50 model is now predicting as expected.
Additionally, there is another section of this class where ResNet50 differs from the other models:
if (self.__modelType == "mobilenetv2"):
image_to_predict = tf.keras.applications.mobilenet_v2.preprocess_input(image_to_predict)
elif (self.__modelType == "full"):
image_to_predict = tf.keras.applications.mobilenet_v2.preprocess_input(image_to_predict)
elif (self.__modelType == "inceptionv3"):
image_to_predict = tf.keras.applications.inception_v3.preprocess_input(image_to_predict)
elif (self.__modelType == "densenet121"):
image_to_predict = tf.keras.applications.densenet.preprocess_input(image_to_predict)
You'll notice ResNet50 has no preprocess_input case here, so the image goes straight into the model as is. This results in some strange prediction values (e.g. [[4.878225e-07 9.999995e-01]] for prediction
). Adding in a 'resnet50' case with image_to_predict = tf.keras.applications.resnet50.preprocess_input(image_to_predict)
returned the prediction values to normal (distribution that sums to 1).
Looking again and I may be wrong. For some reason the keras.application call uses weights=None
and it loads weights in the next line, whereas other models load in line with self.modelPath. I'm not sure what the deal is but changing None to self.modelPath returns the 100% problem. Without it though, I don't see how your model would be loaded in.
Edit: Yeah with some testing this doesn't seem to be the solution. Maybe it's a start though.
I too am getting this same issue with the latest version (2.1.6), using ResNet50, pretrained or custom trained datasets always seem to pick one class at 100% confidence for any picture I throw at it. Using the default training and prediction code from the documentation, correct file structures and 200 experiments with decent accuracy (2 hours of training) model_ex-200_acc-0.964692.h5. I'm going to try my hand with DenseNet121 instead.
Still doesn't work properly, the image was a velvet swimming crab from it's own training data