google-research / pix2seq

Pix2Seq codebase: multi-tasks with generative modeling (autoregressive and diffusion)
Apache License 2.0
857 stars 71 forks source link

TypeError: 'int' object is not subscriptable #23

Open M-Amrollahi opened 1 year ago

M-Amrollahi commented 1 year ago

I have just run the colab and install the requirements. How can I resolve this?

TypeError                                 Traceback (most recent call last)
[<ipython-input-16-75c695310352>](https://localhost:8080/#) in <module>
     20 
     21 # Restore checkpoint.
---> 22 model = model_lib.Model(config)
     23 checkpoint = tf.train.Checkpoint(
     24     model=model, global_step=tf.Variable(0, dtype=tf.int64))

[/content/pix2seq/models/ar_model.py](https://localhost:8080/#) in __init__(self, config, **kwargs)
     50     else:
     51       self.encoder = ResNetTransformer(
---> 52           config.image_size[0], config.image_size[1], config.resnet_variant,
     53           config.resnet_depth, config.resnet_width_multiplier,
     54           config.resnet_sk_ratio, config.num_encoder_layers, config.dim_att,

TypeError: 'int' object is not subscriptable
hesamira commented 1 year ago

Hi, I have also faced this error. Please, help us. Thanks.

chentingpc commented 1 year ago

Looks like the image size should be a tuple instead of int, eg (320, 320) instead of 320. can you try to modify that and see if that works?

M-Amrollahi commented 1 year ago

That solves the issue.

But I do not see any bbox on the result. The image and result are the same and there is no bbox or label on the image.

saxenasaurabh commented 1 year ago

Updating the image_size seems to work for me. This is what I tried:

del config.model.image_size
del config.task.image_size
del config.tasks[0]["image_size"]

config.model.image_size = (640, 640)
config.task.image_size = (640, 640)
config.tasks[0]["image_size"] = (640, 640)
shamitb commented 1 year ago

Still doesnt work for me tried to make the image_size a tuple: config.model.image_size = (640, 640)

shamitb commented 1 year ago

With above changes I get this error:


TypeError Traceback (most recent call last) in 28 29 # Restore checkpoint. ---> 30 model = model_lib.Model(config) 31 checkpoint = tf.train.Checkpoint( 32 model=model, global_step=tf.Variable(0, dtype=tf.int64))

10 frames /usr/local/lib/python3.9/dist-packages/keras/utils/generic_utils.py in validate_kwargs(kwargs, allowed_kwargs, error_message) 513 for kwarg in kwargs: 514 if kwarg not in allowed_kwargs: --> 515 raise TypeError(error_message, kwarg) 516 517

TypeError: ('Keyword argument not understood:', 'synchronized')

saxenasaurabh commented 1 year ago

@shamitb could you please paste the full stacktrace?

bruce2233 commented 10 months ago

same error