pix2seq icon indicating copy to clipboard operation
pix2seq copied to clipboard

TypeError: 'int' object is not subscriptable

Open M-Amrollahi opened this issue 3 years ago • 8 comments

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

M-Amrollahi avatar Nov 27 '22 04:11 M-Amrollahi

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

hesamira avatar Nov 27 '22 06:11 hesamira

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?

chentingpc avatar Nov 28 '22 01:11 chentingpc

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.

M-Amrollahi avatar Nov 28 '22 09:11 M-Amrollahi

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)

saxenasaurabh avatar Dec 03 '22 15:12 saxenasaurabh

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

shamitb avatar Mar 18 '23 23:03 shamitb

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')

shamitb avatar Mar 19 '23 11:03 shamitb

@shamitb could you please paste the full stacktrace?

saxenasaurabh avatar Mar 20 '23 14:03 saxenasaurabh

same error

bruce2233 avatar Nov 05 '23 14:11 bruce2233