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.63k stars 2.19k forks source link

I am getting errors with ImageAI TypeError: object of type 'NoneType' has no len() PLEASE HELP MEEE :'( #325

Open Namanw99 opened 5 years ago

Namanw99 commented 5 years ago

Generating anchor boxes for training images and annotation... Average IOU for 9 anchors: 0.98 Anchor Boxes generated. Detection configuration saved in Person008/json/detection_config.json Some labels have no annotations! Please revise the list of labels in your configuration. Training on: None Training with Batch Size: 4 Number of Experiments: 100


TypeError Traceback (most recent call last)

in () 5 trainer.setDataDirectory(data_directory="Person008") 6 trainer.setTrainConfig(object_names_array=["Person008"], batch_size=4, num_experiments=100, train_from_pretrained_model="pretrained-yolov3.h5") ----> 7 trainer.trainModel() 1 frames /usr/local/lib/python3.6/dist-packages/imageai/Detection/Custom/generator.py in __init__(self, instances, anchors, labels, downsample, max_box_per_image, batch_size, min_net_size, max_net_size, shuffle, jitter, norm) 34 self.net_w = 416 35 ---> 36 if shuffle: np.random.shuffle(self.instances) 37 38 def __len__(self): mtrand.pyx in mtrand.RandomState.shuffle() TypeError: object of type 'NoneType' has no len() I am getting this error when I run from imageai.Detection.Custom import DetectionModelTrainer trainer = DetectionModelTrainer() trainer.setModelTypeAsYOLOv3() trainer.setDataDirectory(data_directory="Person008") trainer.setTrainConfig(object_names_array=["Person008"], batch_size=4, num_experiments=100, train_from_pretrained_model="pretrained-yolov3.h5") trainer.trainModel() help me if you need more details i'll reply to you BUT PLEASE HELP ME
blueclowd commented 5 years ago

Check the annotation. There may be some annotated boxes without class name "Person008" which does not match the parameter _object_namesarray in setTrainConfig()

rola93 commented 5 years ago

First of all, make sure to be running the last version of ImageAI, otherwise upgrade it.

No training samples were read. Check if every thing is correctly set up (the path to the folders with images/annotations). Also consider double checking the annotation files.

Please, update your status on this, or close it otherwise.

VijayaLakshmiArthanari commented 5 years ago

I also checked my xml file. But it shows correctly. I am having latest version of imageai also. Please help me out to solve my problem.

adclama9 commented 5 years ago

you might have added names to your object_names_array that you didn't annotate

VijayaLakshmiArthanari commented 4 years ago

Yes You are right, It's Running bro, Thanks

Thanakorn-VK commented 4 years ago

I got this error how i can fix it. Please help me.

smash-96 commented 4 years ago

you might have added names to your object_names_array that you didn't annotate

My issue was solved with this, I placed the wrong object array name. Also, The imageAI functions are quite outdated as I keep getting a depreciated warning while running my programs. Does anyone know when it'll be updated!

nachiketmore99 commented 4 years ago

I am also getting this error, but in my case, everything works fine when I put all files in the train folder. the error comes as soon as I move some files to the validation folder. same files if put to the train folder works fine. I am using latest version of imageai. does anyone has faced this problem?

asp61735 commented 2 years ago

I found the issue is due to the cache files generated "detection_test_data.pkl". If the annotation labels and images are correct, delete the cache files and try. worked for me.

gandhali28 commented 2 years ago

you might have added names to your object_names_array that you didn't annotate

Can you elaborate above reply more..I could not understand it cleary. I am facing same error above while using yolov3 model .

Plluxury commented 1 year ago

i have a solve for everyone: when u work with labelimg after you do a rectangle u need name all of your labels same name and after put this name in object_names_array. I did it and it worked