TypeError: __init__() got an unexpected keyword argument 'transform'
See original GitHub issue🐛 Bug
Uncaught exception
Traceback (most recent call last):
File "/mnt/data/buduanban_detection/meteo.py", line 103, in <module>
datamodule = ObjectDetectionData.from_coco(
File "/data/miniconda3/envs/torch/lib/python3.9/site-packages/flash/image/detection/data.py", line 386, in from_coco
return cls.from_icedata(
File "/data/miniconda3/envs/torch/lib/python3.9/site-packages/flash/image/detection/data.py", line 220, in from_icedata
return cls(
TypeError: __init__() got an unexpected keyword argument 'transform'
To Reproduce
The code is directly copied from https://lightning-flash.readthedocs.io/en/latest/reference/object_detection.html
Code sample
from dataclasses import dataclass
import albumentations as alb
from icevision.tfms import A
from flash import InputTransform
from flash.core.integrations.icevision.transforms import IceVisionTransformAdapter
from flash.image import ObjectDetectionData
@dataclass
class BrightnessContrastTransform(InputTransform):
image_size: int = 128
def per_sample_transform(self):
return IceVisionTransformAdapter(
[*A.aug_tfms(size=self.image_size), A.Normalize(), alb.RandomBrightnessContrast()]
)
datamodule = ObjectDetectionData.from_coco(
train_folder="data/coco128/images/train2017/",
train_ann_file="data/coco128/annotations/instances_train2017.json",
val_split=0.1,
transform=BrightnessContrastTransform,
batch_size=4,
)
Expected behavior
Environment
- OS (e.g., Linux):
- Python version:
- PyTorch/Lightning/Flash Version (e.g., 1.10/1.5/0.7):
- GPU models and configuration:
- Any other relevant information:
Additional context
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
pytorch __init__() got an unexpected keyword argument 'train'
The error implies that it couldn't recognize the train parameter, in the ImageFolder class. ImageFolder() does not have a parameter train, ...
Read more >TypeError: __init__() got an unexpected keyword argument ...
Another solution including the transformation of the X object in array type in a float64 type from sklearn ...
Read more >TypeError: __init__() got an unexpected keyword ... - GitHub
and it give my a TypeError: init() got an unexpected keyword argument 'target_tensor' my python version is 2.7.15 and torch version is 0.4.0....
Read more >init__() got an unexpected keyword argument 'max_iter'?
TypeError : init() got an unexpected keyword argument 'max_iter'. I m running the linear regression code in Community edition. Google says reinstall --....
Read more >tensor.__init__() got an unexpected keyword argument 'shape'
Running the code above gives the error: TypeError: __init__ () got an unexpected keyword argument 'shape'. The comment below says that tf.zeros_initializer ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

There is a breaking change in the latest version of flash that unifies all transforms in a single API implemented in https://github.com/PyTorchLightning/lightning-flash/pull/1233. Please refer to the
0.7.1version of the docs in order to make this work - https://lightning-flash.readthedocs.io/en/0.7.1/reference/object_detection.htmlIn your particular case you should use
train_transforminstead oftransform(the new API) inObjectDetectionData.from_cococall.Thank you @krshrimali.