Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TinyYOLOv3 Finetuning #613

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

Wheest
Copy link

@Wheest Wheest commented Dec 6, 2020

Have implemented most of the features for performing training with TinyYOLOv3.

However, there are some issues with the anchors which mean that it does not completely work. Some insight from someone with more YOLO knowledge than me would be helpful.

You can finetune with the test code:

from imageai.Detection.Custom import DetectionModelTrainer

trainer = DetectionModelTrainer()
trainer.setModelTypeAsTinyYOLOv3()
trainer.setDataDirectory(data_directory="../data/")
trainer.setTrainConfig(object_names_array=["drone"], batch_size=16, 
                       num_experiments=5,
                       train_from_pretrained_model="../models/yolo-tiny.h5")
trainer.trainModel()

I've assumed from the TinyYOLOv3 definition that we are using 6 instead of 9 anchors.

And that we only have two YOLOs instead of 3. My generator is in Detection/Custom/tinyyolov3_generator.py, my model definition is at Detection/Custom/yolo.py#L346.

When I start finetuning, I get the error:

 File "test.py", line 9, in <module>
    trainer.trainModel()
  File "/home/wheest/proj/ImageAI/imageai/Detection/Custom/__init__.py", line 310, in trainModel
    max_queue_size=8
  File "/home/wheest/.virtualenvs/venv37/lib/python3.7/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "/home/wheest/.virtualenvs/venv37/lib/python3.7/site-packages/keras/engine/training.py", line 1418, in fit_generator
    initial_epoch=initial_epoch)
  File "/home/wheest/.virtualenvs/venv37/lib/python3.7/site-packages/keras/engine/training_generator.py", line 217, in fit_generator
    class_weight=class_weight)
  File "/home/wheest/.virtualenvs/venv37/lib/python3.7/site-packages/keras/engine/training.py", line 1217, in train_on_batch
    outputs = self.train_function(ins)
  File "/home/wheest/.virtualenvs/venv37/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py", line 2715, in __call__
    return self._call(inputs)
  File "/home/wheest/.virtualenvs/venv37/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py", line 2675, in _call
    fetched = self._callable_fn(*array_vals)
  File "/home/wheest/.virtualenvs/venv37/lib/python3.7/site-packages/tensorflow_core/python/client/session.py", line 1472, in __call__
    run_metadata_ptr)
tensorflow.python.framework.errors_impl.InvalidArgumentError: assertion failed: [Condition x == y did not hold element-wise:] [x (yolo_layer_1/SparseSoftmaxCrossEntropyWithLogits/Shape_1:0) = ] [16 13 13...] [y (yolo_layer_1/SparseSoftmaxCrossEntropyWithLogits/strided_slice:0) = ] [16 104 104...]

Any comments or suggestions appreciated!

@codecov
Copy link

codecov bot commented Dec 6, 2020

Codecov Report

Merging #613 (1f7dd5a) into master (1262edc) will decrease coverage by 38.17%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##           master     #613       +/-   ##
===========================================
- Coverage   48.83%   10.66%   -38.18%     
===========================================
  Files          63       24       -39     
  Lines        5856     3450     -2406     
===========================================
- Hits         2860      368     -2492     
- Misses       2996     3082       +86     

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant