xuannianz / keras-GaussianYOLOv3

Gaussian YOLOv3 (An Accurate and Fast Object Detector Using Localization Uncertainty for Autonomous Driving (ICCV, 2019)) implementation in Keras and Tensorflow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Guide to implement

CuongNguyen218 opened this issue · comments

Can you explain to me how to implement loss function Gaussian yolov3 in your code? I want to reimplement it on pytorch

Hi, now you have the loss function implemented in tf, so you just need to figure it out and reimplemented in pytorch.

@xuannianz ,
https://github.com/xuannianz/keras-GaussianYOLOv3/blob/master/model.py#L123-L130
I don't know fm_13_input, fm_26_input, fm_52_input come from where ? Maybe 13 corresponding to y1, 26 to y2 and 52 to y3, right ? Or it comes from train_generator annotations. Sorry because i don't familiar with keras

#3 (comment)

Thank for your Good project! I try to train voc2012 datasets but always have a error :
ModuleNotFoundError: No module named 'utils.compute_overlap'
What Should I do to train a model? How to deal with the datasets?
Thank you

@Byronnar Do you have the 'compute_overlap' module?
If yes, how about replacing

from .common import evaluate
with from eval.common import evaluate

It does not work, I have replaced that , but the problem is not solved...
File "train.py", line 302, in main
args,
File "train.py", line 71, in create_callbacks
from eval.pascal import Evaluate
File "/home/byronnar/yolo3/keras-GaussianYOLOv3/eval/pascal.py", line 18, in
from eval.common import evaluate
File "/home/byronnar/yolo3/keras-GaussianYOLOv3/eval/common.py", line 4, in
from utils.compute_overlap import compute_overlap
ModuleNotFoundError: No module named 'utils.compute_overlap'

Hi, Do you have that module file?
If yes, make sure it is placed right there.
If not, try to build by python setup.py build_ext --inplace as in keras-retinanet.

hi, @xuannianz
I try to train the VOC data, and get this error during val after the first training epoch,

Traceback (most recent call last):
File "train.py", line 351, in
main()
File "train.py", line 346, in main
validation_data=validation_generator
File "/home/user/anaconda3/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 87, in wrapper
return func(*args, **kwargs)
File "/home/user/anaconda3/lib/python3.6/site-packages/keras/engine/training.py", line 2136, in fit_generator
callbacks.on_epoch_end(epoch, epoch_logs)
File "/home/user/anaconda3/lib/python3.6/site-packages/keras/callbacks.py", line 73, in on_epoch_end
callback.on_epoch_end(epoch, logs)
File "/home/user/gaussian_yolo/keras-GaussianYOLOv3/eval/pascal.py", line 73, in on_epoch_end
visualize=False
File "/home/user/gaussian_yolo/keras-GaussianYOLOv3/eval/common.py", line 239, in evaluate
num_fp += false_positives[-1]
IndexError: index -1 is out of bounds for axis 0 with size 0

What should I do? thank you

Hi, Do you have that module file?
If yes, make sure it is placed right there.
If not, try to build by python setup.py build_ext --inplace as in keras-retinanet.

Thank you, that problem has been solved,but I find a new problem(pretrain weiths):
/home/byronnar/anaconda3/envs/dev/lib/python3.6/site-packages/keras/engine/saving.py:1140: UserWarning: Skipping loading of weights for layer conv2d_59 due to mismatch in shape ((1, 1, 1024, 87) vs (255, 1024, 1, 1)).
weight_values[i].shape))
/home/byronnar/anaconda3/envs/dev/lib/python3.6/site-packages/keras/engine/saving.py:1140: UserWarning: Skipping loading of weights for layer conv2d_59 due to mismatch in shape ((87,) vs (255,)).
weight_values[i].shape))
/home/byronnar/anaconda3/envs/dev/lib/python3.6/site-packages/keras/engine/saving.py:1140: UserWarning: Skipping loading of weights for layer conv2d_67 due to mismatch in shape ((1, 1, 512, 87) vs (255, 512, 1, 1)).
weight_values[i].shape))
/home/byronnar/anaconda3/envs/dev/lib/python3.6/site-packages/keras/engine/saving.py:1140: UserWarning: Skipping loading of weights for layer conv2d_67 due to mismatch in shape ((87,) vs (255,)).

How should I do?

Hi @harlem867

false_positives = np.cumsum(false_positives)
true_positives = np.cumsum(true_positives)

if false_positives.shape[0] == 0:
	num_fp += 0
else:
	num_fp += false_positives[-1]
if true_positives.shape[0] == 0:
	num_tp += 0
else:
	num_tp += true_positives[-1]

@Byronnar There are warnings, since your number of classes is not same with coco(80). It does not matter, just skip it.

Thanks, and this code support multi-Gpus training?

@Byronnar hello, where is the setup.py file?

@Byronnar hello, where is the setup.py file?

Don't need the setup.py file, you just add the code :
import pyximport
pyximport.install()

in the train.py.

@xuannianz @Byronnar
Hello, I got another error during the training,

Traceback (most recent call last):
File "train.py", line 354, in
main()
File "train.py", line 349, in main
validation_data=validation_generator
File "/home/user/anaconda3/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 87, in wrapper
return func(*args, **kwargs)
File "/home/user/anaconda3/lib/python3.6/site-packages/keras/engine/training.py", line 2136, in fit_generator
callbacks.on_epoch_end(epoch, epoch_logs)
File "/home/user/anaconda3/lib/python3.6/site-packages/keras/callbacks.py", line 73, in on_epoch_end
callback.on_epoch_end(epoch, logs)
File "/home/user/anaconda3/lib/python3.6/site-packages/keras/callbacks.py", line 397, in on_epoch_end
filepath = self.filepath.format(epoch=epoch + 1, **logs)
KeyError: 'val_loss'

how to solve it?thank you

My bad. You need to add option --compute-val-loss when run train.py.

@xuannianz
thanks a lot , but still have problem,

Loading model, this may take a second...
File "train.py", line 354, in
main()
File "train.py", line 349, in main
validation_data=validation_generator
File "/home/user/anaconda3/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 87, in wrapper
return func(*args, **kwargs)
File "/home/user/anaconda3/lib/python3.6/site-packages/keras/engine/training.py", line 1988, in fit_generator
raise ValueError('When using a generator for validation data, '
ValueError: When using a generator for validation data, you must specify a value for validation_steps.

how to specify it, thank you.

@xuannianz
How can I resolve this error? My datasets are right(I have trained this dataset with other algorithms) ...
File "/home/byronnar/yolo3/keras-GaussianYOLOv3/generators/common.py", line 309, in random_misc_group_entry
assert annotations['bboxes'].shape[0] != 0
AssertionError

what is the meaning of 'annotations['bboxes'].shape[0] '???
Thank you! Look forward to your reply!

@harlem867 check your tf and keras version

@Byronnar assert here is to make sure that all images have associated bboxes. But it is not necessary. You can remove this line.

Hi @harlem867

false_positives = np.cumsum(false_positives)
true_positives = np.cumsum(true_positives)

if false_positives.shape[0] == 0:
	num_fp += 0
else:
	num_fp += false_positives[-1]
if true_positives.shape[0] == 0:
	num_tp += 0
else:
	num_tp += true_positives[-1]

I have changed this code, and trained my own datasets(two category), but there is a problem when I inference...:
ValueError: Layer #249 (named "conv2d_59"), weight <tf.Variable 'conv2d_59/kernel:0' shape=(1, 1, 1024, 87) dtype=float32_ref> has shape (1, 1, 1024, 87), but the saved weight has shape (33, 1024, 1, 1).
What should I do? Thank you

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Hi @harlem867

false_positives = np.cumsum(false_positives)
true_positives = np.cumsum(true_positives)

if false_positives.shape[0] == 0:
	num_fp += 0
else:
	num_fp += false_positives[-1]
if true_positives.shape[0] == 0:
	num_tp += 0
else:
	num_tp += true_positives[-1]

I have changed this code, and trained my own datasets(two category), but there is a problem when I inference...:
ValueError: Layer #249 (named "conv2d_59"), weight <tf.Variable 'conv2d_59/kernel:0' shape=(1, 1, 1024, 87) dtype=float32_ref> has shape (1, 1, 1024, 87), but the saved weight has shape (33, 1024, 1, 1).
What should I do? Thank you

Hi, @Byronnar

Update your model.py file for function:
def yolo_body(anchors, num_classes=2, score_threshold=0.01):
num_classes=2 instead of num_classes=20