I am getting this error in UNet learner after changing resnet34 arch by xresnet34
That doesn’t tell us much at all on how to fix it. We need the full stack trace to be able to do anything. But on a related note unet is only available for the main ResNet architectures, not xresnet so it won’t work OOTB.
Downloading: "https://s3.amazonaws.com/fast-ai-modelzoo/xrn50_940.pth" to /home/david/.cache/torch/checkpoints/xrn50_940.pth
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
~/anaconda3/envs/seg/lib/python3.7/site-packages/tqdm/notebook.py in status_printer(_, total, desc, ncols)
95 if total:
---> 96 pbar = IProgress(min=0, max=total)
97 else: # No total? Show info style bar with no progress tqdm status
NameError: name 'IProgress' is not defined
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-21-698a6d339346> in <module>
1 learn = unet_learner(dls, xresnet34, metrics=[tumour,Dice(),JaccardCoeff()],wd=1e-2,
----> 2 pretrained=True,normalize=True, config=config).to_fp16()
~/anaconda3/envs/seg/lib/python3.7/site-packages/fastcore/utils.py in _f(*args, **kwargs)
424 log_dict = {**func_args.arguments, **{f'{k} (not in signature)':v for k,v in xtra_kwargs.items()}}
425 log = {f'{f.__qualname__}.{k}':v for k,v in log_dict.items() if k not in but}
--> 426 inst = f(*args, **kwargs) if to_return else args[0]
427 init_args = getattr(inst, 'init_args', {})
428 init_args.update(log)
~/anaconda3/envs/seg/lib/python3.7/site-packages/fastai2/vision/learner.py in unet_learner(dls, arch, loss_func, pretrained, cut, splitter, config, n_in, n_out, normalize, **kwargs)
193 if config is None: config = unet_config()
194 meta = model_meta.get(arch, _default_meta)
--> 195 body = create_body(arch, n_in, pretrained, ifnone(cut, meta['cut']))
196 size = dls.one_batch()[0].shape[-2:]
197 if n_out is None: n_out = get_c(dls)
~/anaconda3/envs/seg/lib/python3.7/site-packages/fastai2/vision/learner.py in create_body(arch, n_in, pretrained, cut)
64 def create_body(arch, n_in=3, pretrained=True, cut=None):
65 "Cut off the body of a typically pretrained `arch` as determined by `cut`"
---> 66 model = arch(pretrained=pretrained)
67 _update_first_layer(model, n_in, pretrained)
68 #cut = ifnone(cut, cnn_config(arch)['cut'])
~/anaconda3/envs/seg/lib/python3.7/site-packages/fastai2/vision/models/xresnet.py in xresnet34(pretrained, **kwargs)
61
62 def xresnet18 (pretrained=False, **kwargs): return _xresnet(pretrained, 1, [2, 2, 2, 2], **kwargs)
---> 63 def xresnet34 (pretrained=False, **kwargs): return _xresnet(pretrained, 1, [3, 4, 6, 3], **kwargs)
64 def xresnet50 (pretrained=False, **kwargs): return _xresnet(pretrained, 4, [3, 4, 6, 3], **kwargs)
65 def xresnet101(pretrained=False, **kwargs): return _xresnet(pretrained, 4, [3, 4, 23, 3], **kwargs)
~/anaconda3/envs/seg/lib/python3.7/site-packages/fastai2/vision/models/xresnet.py in _xresnet(pretrained, expansion, layers, **kwargs)
57 url = 'https://s3.amazonaws.com/fast-ai-modelzoo/xrn50_940.pth'
58 res = XResNet(ResBlock, expansion, layers, **kwargs)
---> 59 if pretrained: res.load_state_dict(load_state_dict_from_url(url, map_location='cpu')['model'], strict=False)
60 return res
61
~/anaconda3/envs/seg/lib/python3.7/site-packages/torch/hub.py in load_state_dict_from_url(url, model_dir, map_location, progress, check_hash)
490 sys.stderr.write('Downloading: "{}" to {}\n'.format(url, cached_file))
491 hash_prefix = HASH_REGEX.search(filename).group(1) if check_hash else None
--> 492 download_url_to_file(url, cached_file, hash_prefix, progress=progress)
493
494 # Note: extractall() defaults to overwrite file if exists. No need to clean up beforehand.
~/anaconda3/envs/seg/lib/python3.7/site-packages/torch/hub.py in download_url_to_file(url, dst, hash_prefix, progress)
409 sha256 = hashlib.sha256()
410 with tqdm(total=file_size, disable=not progress,
--> 411 unit='B', unit_scale=True, unit_divisor=1024) as pbar:
412 while True:
413 buffer = u.read(8192)
~/anaconda3/envs/seg/lib/python3.7/site-packages/tqdm/notebook.py in __init__(self, *args, **kwargs)
207 total = self.total * unit_scale if self.total else self.total
208 self.container = self.status_printer(
--> 209 self.fp, total, self.desc, self.ncols)
210 self.sp = self.display
211
~/anaconda3/envs/seg/lib/python3.7/site-packages/tqdm/notebook.py in status_printer(_, total, desc, ncols)
102 # #187 #451 #558
103 raise ImportError(
--> 104 "FloatProgress not found. Please update jupyter and ipywidgets."
105 " See https://ipywidgets.readthedocs.io/en/stable"
106 "/user_install.html")
ImportError: FloatProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
I am getting the same error with resnet50!!
Is there any place to see available architectures and if they are pretrained?
The error comes from tqdm, used by torch.hub to show the progress bar when you download the model. This has nothing to do with fastai. Also it does tell you what to do: update jupyter and ipywidgets and tells you to go to https://ipywidgets.readthedocs.io/en/stable/user_install.html to see how.
I tried updating ipywidgets and is working!
Closing my issue in github right now. Sorry
The error comes from tqdm, used by torch.hub to show the progress bar when you download the model. This has nothing to do with fastai. Also it does tell you what to do: update jupyter and ipywidgets.
fastbook 01 notebook, widgets not defined, I update both ipywidgets and jupyter notebook, add add the import ipywidgets as widgets
and it is not the same problem, but it is working now.
Yeah, I solved it in that way. I forgot to update