ImageAI
ImageAI copied to clipboard
Custom Object Detection Model - My model doesn't work on my own dataset
My model comes out with good accuracy after 100 epochs, however, when to detect the objects in a random image, nothing is detected. Someone here really used ImageAI on your own dataset? Is there some limitation according to image resolution?
Cheers
Hi,
Can you give me some details about your custom dataset. So I can get a better view about the situation.
_import imageai from imageai.Detection.Custom import DetectionModelTrainer train the custom model trainer = DetectionModelTrainer() trainer.setModelTypeAsYOLOv3() trainer.setDataDirectory(data_directory='scada_all') trainer.setTrainConfig(object_names_array=["tag"], batch_size=4, num_experiments= 100, train_from_pretrained_model=(\bla\pretrained-yolov3.h5) train = trainer.trainModel() print(train) evaluation of the model
metrics = trainer.evaluateModel(model_path='scada_all/models', json_path='scada_all/json/detection_config.json', iou_threshold=0.5, object_threshold=0.3, nms_threshold=0.5) print(metrics)_
my model loss = 13.616 and mAP =~ 80%
image detection detector = CustomObjectDetection() detector.setModelTypeAsYOLOv3() detector.setModelPath('scada_all/models/detection_model-exBLABLABLA') detector.setJsonPath('scada_all/json/detection_config.json') detector.loadModel() detections = detector.detectObjectsFromImage(input_image=input_path, output_image_path=output_path) for detection in detections: print(detection['name'], ' : ', detection['percentage_probability'], ' : ', detection['box_points'])
my dataset is made of images like this, where I want to detect one of this tags. I did data augmentation to increase the amount of images to train the model.
how big are your images compared to the objects you want to detect ?
I have different styles of images. I'm not sure if the quality is too low.
And I would detect in a picture very similar, like this:
How big is the resolution in like pixels
it varies like in this examples, from 76x57 to 1037x612
This range should not be a problem. The problem might be you labels itself bc they have a lot of background.
If those 3 images you send me where cut our labels then are the objects in them are too small compared to the background.
They should look more like this.
Thanks a lot! The object detection model works, but not for every input image I provide. I'll try to improve my dataset.
Thanks a lot again!!
@marbortoli Hey how it is going could you fix your problem ?
I could fix in general. The main issue now is that the model doesn't work for every image I give as an input. I'm increasing the epochs to try to solve the problem :)
That is the problem regarding to the object detecting using machine learning that the accuracy will never be 100 % Btw if u train the model to long it could decrease the acc on images outside you training se. So if the loss is stable on a low lvl for a long time you should stop training to prevent that
Thanks! So far my accuracy is very low anyways. I don't know if its due to my dataset, but I provided a lot of images. However many of them are from data augmentation and I don't know if this can compromise my training in some way.
What kind of augmentation do u use ?
Augmentor library from python
@marbortoli hi can u specify exactly what u used things like rotation or random cropping ?
oh sorry for the delay.
p.rotate(probability=0.9, max_left_rotation=10, max_right_rotation=10) p.zoom(probability=0.3, min_factor=1.1, max_factor=1.6)