latent-composition
latent-composition copied to clipboard
ImportError: cannot import name 'model_urls' from 'torchvision.models.alexnet'
Hey.
When running interactive-masking.ipynb nootebook in colab on line nets = networks.define_nets(model_type, domain) the ImportError is raised
ImportError Traceback (most recent call last)
[<ipython-input-7-dedb075f180e>](https://localhost:8080/#) in <cell line: 0>()
4
5 model_type, domain = dropdown.split()
----> 6 nets = networks.define_nets(model_type, domain)
7 outdim = nets.setting['outdim']
3 frames
[/content/latent-composition/networks/networks.py](https://localhost:8080/#) in define_nets(nettype, domain, use_RGBM, use_VAE, ckpt_path, load_encoder, device)
10 return ProgganNets(domain, use_RGBM, use_VAE, ckpt_path, load_encoder, device)
11 elif nettype == 'stylegan':
---> 12 return StyleganNets(domain, use_RGBM, use_VAE, ckpt_path, load_encoder, device)
13 else:
14 raise NotImplementedError
[/content/latent-composition/networks/networks.py](https://localhost:8080/#) in __init__(self, domain, use_RGBM, use_VAE, ckpt_path, load_encoder, device)
104 class StyleganNets(Nets):
105 def __init__(self, domain, use_RGBM=True, use_VAE=False, ckpt_path='pretrained', load_encoder=True, device='cuda'):
--> 106 from . import stylegan_networks
107 setting = stylegan_networks.stylegan_setting(domain)
108 self.generator = stylegan_networks.load_stylegan(
[/content/latent-composition/networks/stylegan_networks.py](https://localhost:8080/#) in <module>
1 import torch, os
----> 2 from utils import customnet, util
3 from argparse import Namespace
4 from utils.pt_stylegan2 import get_generator
5 from collections import OrderedDict
[/content/latent-composition/utils/customnet.py](https://localhost:8080/#) in <module>
7 from collections import OrderedDict
8 from torchvision.models import resnet
----> 9 from torchvision.models.alexnet import model_urls as alexnet_model_urls
10
11 class CustomResNet(nn.Module):
ImportError: cannot import name 'model_urls' from 'torchvision.models.alexnet' (/usr/local/lib/python3.11/dist-packages/torchvision/models/alexnet.py)
Looks like the code is incompatible with recent version of torchvision @ https://download.pytorch.org/whl/cu124/torchvision-0.21.0%2Bcu124-cp311-cp311-linux_x86_64.whl.