'str' object is not callable

it shows the error is ‘str’ object is not callable ,but i check i don’t use redefine str, so i don’t know how to solve this problem .

I would guess that one of your transform is just a string instead of being a module?

thank you very much, but i don’t konw what your means, can you explain more deatials ,thanks again

it seems like t in ‘img = t(img)’ is not a module, it may be just a string

thank you for your answer, this is the code in the picture ,it comes from transform.py. can you tell me how to solve this problem thank you very much

when you init the class Compose, the transforms should be a list of modules

thanks so much , this code "img = t(img)"it comes from pytoch, so i don’t think it will wrong. so i should check my init code? it wil be very thankful if you can tell me how to write the right code. those are pictures that i think use the init code. thanks again

delete the comments, it is regarded as a string. check transform_test too

1 Like

i solve this problem,i am so happy. thanks again, but i don’t understand why it will be regraded as a string,
“”" “”" it should be regarded as comment?. Anyway i am so appreciate for your help

Check out this link.

As part of the Python course it is taught that in order to do a multiline comment one should use """triple quotes""" . This is wrong. Python only has one way of doing comments and that is using # .

Triple quotes are treated as regular strings with the exception that they can span multiple lines. By regular strings I mean that if they are not assigned to a variable they will be immediately garbage collected as soon as that code executes. hence are not ignored by the interpreter in the same way that #a comment is.

The only exception to the garbage collection fact is when they are placed immediately after a function or class definition or on top of a module, in which case they are called docstrings and made available via the special variable myobj.__doc__ .

Due to the existance of docstrings I’ve seen a lot of people confused about the use of """ elsewhere.

I suggest that the multiline comment lesson is removed or replaced with the instructions from the official PEP8 - Block comments section.

Python only has one way of doing comments and that is using # .

got it , thanks so much