Closed rohitgr7 closed 1 year ago
@rohitgr7 Thanks for raising this. I think what happens is deepcopy is trying to initialize the ResNet50_Weights
enum by passing its value instead of its name. Is there a reason you are saving weights_backbone
into the object? You won't be able to change its value after initialization. If it's for informational purposes, you could store its string value.
@pmeier Any idea if we can patch the original _Weights
enum classes to handle more gracefully this scenario?
hey @datumbox, thank you for your reply.
this wasn't the actual use case where we got this issue. I just added a simple example to showcase the error.
In Lightning, we use LightningModule
, which handles hyper-parameters, so as a user, I can save this as a hparam, but it's not possible right now. Of course, a string is a workaround.
That makes sense. Could you clarify if you are interested in storing the name or the value of the param in your real use-case? Both of the following work but I'm not sure if that's what you want:
from copy import deepcopy
from torchvision.models.resnet import ResNet50_Weights
deepcopy(ResNet50_Weights.IMAGENET1K_V1.value)
deepcopy(ResNet50_Weights.IMAGENET1K_V1.name)
so, we use jsonargparse for our cli and it tries to parse the defaults of the retinanet function, which we reported in https://github.com/omni-us/jsonargparse/issues/187 and got fixed on their side, but then I thought to get the end issue fixed on torchvision side.
The default here is: ResNet50_Weights.IMAGENET1K_V1
, which is an enum .
so if deepcoping these enums is not possible, maybe change the default in the retinanet function to ResNet50_Weights.IMAGENET1K_V1.name
? Atleast that will solve my issue partially. But again making then deepcopyable should be the actual fix.
@rohitgr7 Thanks for the clarifications. Let me sync with @pmeier when he is back to see what's the best option here.
🐛 Describe the bug
Deepcoping retinanet fails
Error:
In short this fails:
Versions