TNTWEN / OpenVINO-YOLO-Automatic-Generation

MIT License
25 stars 1 forks source link

Will the code work for yolov4-tiny model after applying pruning #5

Closed Abhishek672 closed 2 years ago

Abhishek672 commented 2 years ago

Hey @TNTWEN I am using the pruning code given in yolov3-channel-and-layer-pruning. I generated the new .cfg and .weights file. Can I convert my pruned darknet model to tflite, do quantization and detections for a given sample image?

Thanks

TNTWEN commented 2 years ago

This repo could convert pruned yolo from yolov3-channel-and-layer-pruning to tensorflow1.x and then convert to openvino(support int8 quantization ) . But i'm not sure whether you could use it in tflite.

Abhishek672 commented 2 years ago

Thanks for the reply @TNTWEN Do you have any other references to convert pruned model to tflite+int8 quantization?

TNTWEN commented 2 years ago

Sorry,i don't know :joy:

Abhishek672 commented 2 years ago

Hey @TNTWEN I have trained yolov4-tiny model on a small dataset of size ~64 with augmentations (total size is 450) for a single class. For a given test dataset the original model is giving 89% P,R values. Then I did the sparse training on the model with --s 0.001 and --prune 0 for 300 epochs. For the same test dataset the sparse model is giving 34% Recall, which is very low. I tried for s [0.01, 0.001, 0.0001] and the results are same. Is it the epochs or the size of training dataset that is causing problem? Or there is any other issue? I am stuck into this for a week now.

Any suggestions??

TNTWEN commented 2 years ago

Maybe it's because your dataset is too small . Or sparse less epoch,like 150/100.. epochs Although the sparse model only has 34% Recall,just prune it ,and see how much could Recall reach after finetuing.

Abhishek672 commented 2 years ago

Thanks for fast reply @TNTWEN

The trained baseline model is doing good detections on test data. The sparse training is saturating at 30 epochs itself and during sparse training my P R values are also reaching upto 0.9. But when I do the inference on test set the recall drops to 34%. Logically the sparse trained network should also give the same results as the original model for any test set. I also did pruning with different prune ratios after sparsity training, fine tuned the model for 200 epochs, but the inference results on the test set is again same. (Recall 34%). It is unable to identify objects.

So is it the dataset size that I have to increase?

TNTWEN commented 2 years ago

Your dataset is train/valid/test or train/test? If you only have train/test dataset,why the P R values you get are different ?

Abhishek672 commented 2 years ago

Hey @TNTWEN Dataset I divided to train/test using process.py during training. The 34 recall is what I computed manually on a given test set, by looking at inference results. P R during training epochs are good, but detections on the unseen images is very bad.

Abhishek672 commented 2 years ago

@TNTWEN , I think it is the size of the training dataset for the above issue. I was doing the baseline training of yolov4 tiny using train.py. I ran the model for 200 epochs but still the P R values are 0.12. Any training hacks to get good convergence of model at early epochs?

Thanks. Will be closing the issue after this.

TNTWEN commented 2 years ago

@Abhishek672 Maybe you could try darknet. If darknet's P R values are still very low,then you can only expand your dataset

Abhishek672 commented 2 years ago

@TNTWEN , yeah training in darknet solves the issue for me. Thanks