zhen8838 / K210_Yolo_framework

Yolo v3 framework base on tensorflow, support multiple models, multiple datasets, any number of output layers, any number of anchors, model prune, and portable model to K210 !
MIT License
248 stars 73 forks source link

Pre-trained models not work. Need simple explanation how code is working and simple and straightforward code for transfer learning #15

Closed easy-and-simple closed 4 years ago

easy-and-simple commented 4 years ago

Hello Pre-trained models doesn't work. Need simple explanation how code is working and simple and straightforward code for transfer learning I converted one of pre-trained models, loaded in maix board, and run, but it not detect anything. On maix board it is running without errors, but x and y are always 0 and it shows that is detected only 1 class all the time no matter what is captured by camera. What is pre-trained of these models if they are not detecting anything? I didn't tried to load weights yet because I expect that if model is pre-trained it contains trained weights.

Also I can't understand if there pre-trained models have top layer or not and what to do with it. I want to use transfer learning method to train model on my small and simple image dataset, so I need simple explanation how to write my simple code that compile and fit model for transfer learning. I tried to track in code what it is doing but it is too complex and complicated and there is no any comments in code explaining that and why is doing

zhen8838 commented 4 years ago

Pre-trained's weights only load in to backbone, the detect head's weights need training.

I suggest you first run training on voc dataset.

easy-and-simple commented 4 years ago

What is pre-trained then? Pre-trained means that models are already trained for general use and all weights are set accordingly. For example original yolo code need to be compiled, then are loaded corresponding weights and this is enough to work without any training. What is sense to have pre-trained models that I need to train? Once more your code is obviously for tensorflow v1 and current version is already v2 that means it will not work I can't understand why all should be so complicated I don't want to do things that I don't understand. Could you explain how things work? I am new to ML but as I understand you are using some type of transfer learning where you use mobilenet model but compile and fit/training is according to yolo rules. Key moments here are modifications of original mobilenet keras model for matching k210, and parameters used in compile and fit functions that are used after modified mobilenet model is loaded. Because I want to make my yolo model for k210 that detects only few classes of objects, for example cars, people and dogs, I need to know what is most basic and simple way to do it. For example

  1. what I need to modify in original mobilenet1/2 keras models in order to make it compatible with K210
  2. how to load model without top layer and what layers I need to add to model and when, how and what weights I need to load and what part of model I need to freeze before to start training
  3. What parameters I need to pass to compile and fit functions
  4. How to train it
  5. What must include my training image dataset, what must be directory structure and other parameters and requirements
  6. Any other things I need in order to make it running on k210
zhen8838 commented 4 years ago

The mobilenet-Yolo model in this repo has been modified to fit k210, but the pre-trained weights are only for the original mobilenet. So when load pre-trained weights still need training.

  1. You do not need to modify, I already modified.
  2. My code will be automated load pre-trained weights.
  3. At first, I suggest using default parameters.
  4. Please refer to Readme
  5. If you need training own dataset, just organize your dataset structure as VOC dataset, and follow the Readme.
  6. You need a post-process code. I have been given a simple example in yolo3_frame_test_public
easy-and-simple commented 4 years ago

Your guide how to use your project is vary bad You do not explain anything What is the sense to supply weights if they are not working and people will need to do training model in any way? Model have almost 3.2 million trainable parameters, how long I need to train it to have acceptable accuracy and what is the sense of this exercise? You don't want to tell me how to make model to detect only few classes(from 1 to 5 classes for example). If I need pre-trained model with bad accuracy and more classes I could use yolo 20 classes model supplied by Kandrite By the way only thing you have been modified in mobilenet model is padding

zhen8838 commented 4 years ago

This repo is only used as a set of training to deployment process.

The pre-trained model is not meaningless, it will accelerate the model convergence.

The modification of mobilenet is not only padding, please take a closer look.

easy-and-simple commented 4 years ago

No any acceleration from your pre-trained models because training starts with 0 accuracy, which means that weights in your models are set absolutely random