Skip to content

TinyYOLOv3 Finetuning#613

Open
Wheest wants to merge 2 commits intoOlafenwaMoses:masterfrom
Wheest:feat/tinyyolov3
Open

TinyYOLOv3 Finetuning#613
Wheest wants to merge 2 commits intoOlafenwaMoses:masterfrom
Wheest:feat/tinyyolov3

Conversation

@Wheest
Copy link
Copy Markdown

@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
Copy Markdown

codecov bot commented Dec 6, 2020

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

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