OlafenwaMoses / ImageAI

A python library built to empower developers to build applications and systems with self-contained Computer Vision capabilities
https://www.genxr.co/#products
MIT License
8.64k stars 2.19k forks source link

Multiple Errors #832

Open rellyc opened 9 months ago

rellyc commented 9 months ago

Hello, I tried training image recognition AI using the code:

from imageai.Classification.Custom import ClassificationModelTrainer

model_trainer = ClassificationModelTrainer() model_trainer.setModelTypeAsResNet50() model_trainer.setDataDirectory("idenprof") model_trainer.trainModel(num_objects=10, num_experiments=200, enhance_data=True, batch_size=32, show_network_summary=True)

Received there errors:

C:\Users\Optiplex3070\anaconda3\python.exe "C:\Users\Optiplex3070\Downloads\python training\idenprof-jpg\FirstTraining.py" C:\Users\Optiplex3070\AppData\Roaming\Python\Python311\site-packages\torchvision\models_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead. warnings.warn( C:\Users\Optiplex3070\AppData\Roaming\Python\Python311\site-packages\torchvision\models_utils.py:223: UserWarning: Arguments other than a weight enum or None for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing weights=None. warnings.warn(msg) C:\Users\Optiplex3070\AppData\Roaming\Python\Python311\site-packages\torchvision\models\inception.py:43: FutureWarning: The default weight initialization of inception_v3 will be changed in future releases of torchvision. If you wish to keep the old behavior (which leads to long initialization times due to scipy/scipy#11299), please set init_weights=True. warnings.warn( Traceback (most recent call last): File "C:\Users\Optiplex3070\Downloads\python training\idenprof-jpg\FirstTraining.py", line 6, in model_trainer.trainModel(num_objects=10, num_experiments=200, enhance_data=True, batch_size=32, show_network_summary=True) TypeError: ClassificationModelTrainer.trainModel() got an unexpected keyword argument 'num_objects'

rellyc commented 9 months ago

it only works with model_trainer.trainModel(num_experiments=200, batch_size=32) if I remove num_objects=10 enhance_data=True show_network_summary=True Also, how can I make it use the GPU? (nVidia 1650 super, Conda installed). Tensorflow is installed. It throws Training with CPU. This might cause slower train.

6monkeyrs commented 9 months ago

TypeError: ClassificationModelTrainer.trainModel() got an unexpected keyword argument 'num_objects'

This error happens when you have a missmatch on number of class you have on your label data vs what you are telling the trainModel you are expecting.

for example, you may have 5 annotation types for class, but on your num_objects is set to 10