AttributeError: 'EfficientNet' object has no attribute 'act1' on colab

See original GitHub issue

I’m trying to follow the README on colab.

I do:

!git clone https://github.com/autonomousvision/stylegan_xl.git
%cd stylegan_xl
!gdown 1aAJCZbXNHyraJ6Mi13dSbe7pTyfPXha0
!unzip few-shot-image-datasets.zip
!mkdir data
!python dataset_tool.py --source=./few-shot-images/pokemon --dest=./data/pokemon128.zip \
  --resolution=128x128 --transform=center-crop
!python dataset_tool.py --source=./few-shot-images/pokemon --dest=./data/pokemon64.zip \
  --resolution=64x64 --transform=center-crop
!python dataset_tool.py --source=./few-shot-images/pokemon --dest=./data/pokemon32.zip \
  --resolution=32x32 --transform=center-crop
!python dataset_tool.py --source=./few-shot-images/pokemon --dest=./data/pokemon16.zip \
  --resolution=16x16 --transform=center-crop
!pip3 install timm ftfy
!python train.py --outdir=./training-runs/pokemon --cfg=stylegan3-t --data=./data/pokemon16.zip \
    --gpus=1 --batch=64 --mirror=1 --snap 10 --batch-gpu 8 --kimg 10000 --syn_layers 10

But I get this error:


Constructing networks...
loaded imagenet embeddings from in_embeddings/tf_efficientnet_lite0.pkl: Embedding(1000, 320)
Downloading: "https://dl.fbaipublicfiles.com/deit/deit_base_distilled_patch16_224-df68dfff.pth" to /root/.cache/torch/hub/checkpoints/deit_base_distilled_patch16_224-df68dfff.pth
Downloading: "https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_efficientnet_lite0-0aa007d2.pth" to /root/.cache/torch/hub/checkpoints/tf_efficientnet_lite0-0aa007d2.pth
Traceback (most recent call last):
  File "train.py", line 336, in <module>
    main()  # pylint: disable=no-value-for-parameter
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "train.py", line 321, in main
    launch_training(c=c, desc=desc, outdir=opts.outdir, dry_run=opts.dry_run)
  File "train.py", line 104, in launch_training
    subprocess_fn(rank=0, c=c, temp_dir=temp_dir)
  File "train.py", line 49, in subprocess_fn
    training_loop.training_loop(rank=rank, **c)
  File "/content/stylegan_xl/training/training_loop.py", line 171, in training_loop
    D = dnnlib.util.construct_class_by_name(**D_kwargs, **common_kwargs).train().requires_grad_(False).to(device) # subclass of torch.nn.Module
  File "/content/stylegan_xl/dnnlib/util.py", line 303, in construct_class_by_name
    return call_func_by_name(*args, func_name=class_name, **kwargs)
  File "/content/stylegan_xl/dnnlib/util.py", line 298, in call_func_by_name
    return func_obj(*args, **kwargs)
  File "/content/stylegan_xl/pg_modules/discriminator.py", line 174, in __init__
    feat = F_RandomProj(bb_name, **backbone_kwargs)
  File "/content/stylegan_xl/pg_modules/projector.py", line 107, in __init__
    proj_type=self.proj_type, expand=self.expand)
  File "/content/stylegan_xl/pg_modules/projector.py", line 59, in _make_projector
    pretrained = _make_pretrained(backbone)
  File "/content/stylegan_xl/feature_networks/pretrained_builder.py", line 396, in _make_pretrained
    pretrained = _make_efficientnet(model)
  File "/content/stylegan_xl/feature_networks/pretrained_builder.py", line 121, in _make_efficientnet
    model.conv_stem, model.bn1, model.act1, *model.blocks[0:2]
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1208, in __getattr__
    type(self).__name__, name))
AttributeError: 'EfficientNet' object has no attribute 'act1'
[ ]

Check out this colab

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
Gad1001commented, Aug 14, 2022

Hi @turian ,

about your first problem you basically need: !pip install timm==0.5.4

about the second one try: pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f or if you use conda: conda install pytorch==1.9.0 torchvision==0.10.0 torchaudio==0.9.0 cudatoolkit=11.3 -c pytorch -c conda-forge

i have managed to run it in colab in the past so if you meet more errors will be glad to help

0reactions
Gad1001commented, Dec 8, 2022

@turian see below !pip install timm==0.5.4 !pip install ftfy !pip install Ninja !pip install setuptools==59.5.0 !pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

Read more comments on GitHub >

github_iconTop Results From Across the Web

colab doesn't work · Issue #90 · autonomousvision ... - GitHub
Trying to run the example colab notebook fails with the error AttributeError: 'EfficientNet' object has no attribute 'act1'.
Read more >
keras - Tensorflow 2 /Google Colab / EfficientNet Training
The problem is the way you import the efficientnet. You import it from the Keras package and not from the TensorFlow.Keras package.
Read more >
Adding EfficientNet to fastai vision - fast.ai Course Forums
AttributeError : 'SqueezeExcite' object has no attribute 'gate'[BUG] Issue title… Do anybody knows, why I am getting this weird error while ...
Read more >
efficientnet-pytorch - PyPI
I am working on implementing it as you read this :) About EfficientNetV2: EfficientNetV2 is a new family of convolutional networks that have...
Read more >
No such operator image::read_file on google colab
I have created a NN to train a custom dataset. The code was running so far until today when I am seeing the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found