Keras-yolo3: Syntax error

Created on 8 Jul 2018  路  2Comments  路  Source: qqwweee/keras-yolo3

Hi, I have the following error:

$ python train.py
File "train.py", line 130
[*model_body.output, *y_true])
^
SyntaxError: invalid syntax

I am using python2. Is it possible to modify this part to make the code working?

Most helpful comment

you can change the code
from:
model_loss = Lambda(yolo_loss, output_shape=(1,), name='yolo_loss',
arguments={'anchors': anchors, 'num_classes': num_classes, 'ignore_thresh': 0.5})(
[*model_body.output, *y_true])
model = Model([model_body.input, *y_true], model_loss)
to:
lst_tensor = [t for t in model_body.output]
lst_tensor_y_true = [y for y in y_true]
lst_tensor.extend(lst_tensor_y_true)
model_loss = Lambda(yolo_loss, output_shape=(1,), name='yolo_loss',
arguments={'anchors': anchors, 'num_classes': num_classes, 'ignore_thresh': 0.5})(
lst_tensor)
model_tensor = [model_body.input]
model_tensor.extend(lst_tensor_y_true)
model = Model(model_tensor, model_loss)

All 2 comments

you can change the code
from:
model_loss = Lambda(yolo_loss, output_shape=(1,), name='yolo_loss',
arguments={'anchors': anchors, 'num_classes': num_classes, 'ignore_thresh': 0.5})(
[*model_body.output, *y_true])
model = Model([model_body.input, *y_true], model_loss)
to:
lst_tensor = [t for t in model_body.output]
lst_tensor_y_true = [y for y in y_true]
lst_tensor.extend(lst_tensor_y_true)
model_loss = Lambda(yolo_loss, output_shape=(1,), name='yolo_loss',
arguments={'anchors': anchors, 'num_classes': num_classes, 'ignore_thresh': 0.5})(
lst_tensor)
model_tensor = [model_body.input]
model_tensor.extend(lst_tensor_y_true)
model = Model(model_tensor, model_loss)

@TianboChen Thank you for your answer. Besides, I modified line 182 of train.py
-yield [image_data, *y_true], np.zeros(batch_size)
+yield [image_data] + y_true, np.zeros(batch_size)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maiminh1996 picture maiminh1996  路  5Comments

ISSstone picture ISSstone  路  5Comments

wingNine picture wingNine  路  5Comments

jinbooooom picture jinbooooom  路  4Comments

ISSstone picture ISSstone  路  4Comments