nupurkmr9 / vision-aided-gan

Ensembling Off-the-shelf Models for GAN Training (CVPR 2022 Oral)
https://www.cs.cmu.edu/~vision-aided-gan/
MIT License
382 stars 26 forks source link

urllib.error.URLError: <urlopen error Tunnel connection failed: 403 Forbidden #5

Closed swing148 closed 2 years ago

swing148 commented 2 years ago

Hello,your work is great ! ^_^But,When I was running this code, this error occurred. code: python train.py --outdir models/ --data datasets/AnimalFace-dog.zip --kimg 4000 --cfg stylegan3-t --gpus 2 --gamma 10 \ --batch 16 --cv input-clip-output-conv_multi_level --cv-loss multilevel_sigmoid_s --mirror 1 --aug ada --warmup 5e5 error: Constructing networks... Traceback (most recent call last): File "/root/.local/conda/envs/stylegan3/lib/python3.9/urllib/request.py", line 1346, in do_open h.request(req.get_method(), req.selector, req.data, headers, File "/root/.local/conda/envs/stylegan3/lib/python3.9/http/client.py", line 1285, in request self._send_request(method, url, body, headers, encode_chunked) File "/root/.local/conda/envs/stylegan3/lib/python3.9/http/client.py", line 1331, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/root/.local/conda/envs/stylegan3/lib/python3.9/http/client.py", line 1280, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/root/.local/conda/envs/stylegan3/lib/python3.9/http/client.py", line 1040, in _send_output self.send(msg) File "/root/.local/conda/envs/stylegan3/lib/python3.9/http/client.py", line 980, in send self.connect() File "/root/.local/conda/envs/stylegan3/lib/python3.9/http/client.py", line 1447, in connect super().connect() File "/root/.local/conda/envs/stylegan3/lib/python3.9/http/client.py", line 956, in connect self._tunnel() File "/root/.local/conda/envs/stylegan3/lib/python3.9/http/client.py", line 930, in _tunnel raise OSError(f"Tunnel connection failed: {code} {message.strip()}") OSError: Tunnel connection failed: 403 Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/root/GANs/vision-aided-gan-main/./stylegan3/train.py", line 326, in main() # pylint: disable=no-value-for-parameter File "/root/.local/conda/envs/stylegan3/lib/python3.9/site-packages/click/core.py", line 1128, in call return self.main(args, kwargs) File "/root/.local/conda/envs/stylegan3/lib/python3.9/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/root/.local/conda/envs/stylegan3/lib/python3.9/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, ctx.params) File "/root/.local/conda/envs/stylegan3/lib/python3.9/site-packages/click/core.py", line 754, in invoke return __callback(args, kwargs) File "/root/GANs/vision-aided-gan-main/./stylegan3/train.py", line 321, in main launch_training(c=c, desc=desc, outdir=opts.outdir, dry_run=opts.dry_run) File "/root/GANs/vision-aided-gan-main/./stylegan3/train.py", line 98, in launch_training subprocess_fn(rank=0, c=c, temp_dir=temp_dir) File "/root/GANs/vision-aided-gan-main/./stylegan3/train.py", line 48, in subprocess_fn training_loop.training_loop(rank=rank, c) File "/root/GANs/vision-aided-gan-main/stylegan3/training/training_loop.py", line 167, in training_loop cvD = dnnlib.util.construct_class_by_name(cvD_kwargs, device=device).train().requiresgrad(False).to(device) File "/root/GANs/vision-aided-gan-main/stylegan3/dnnlib/util.py", line 303, in construct_class_by_name return call_func_by_name(*args, func_name=class_name, *kwargs) File "/root/GANs/vision-aided-gan-main/stylegan3/dnnlib/util.py", line 298, in call_func_by_name return func_obj(args, kwargs) File "/root/.local/lib/python3.9/site-packages/vision_aided_loss/cv_discriminator.py", line 98, in init self.cv_ensemble = CVBackbone(cv_type, output_type, diffaug=diffaug, device=device) File "/root/.local/lib/python3.9/site-packages/vision_aided_loss/cvmodel.py", line 207, in init model = model(cv_type=cvtype).requiresgrad(False).to(device) File "/root/.local/lib/python3.9/site-packages/vision_aidedloss/cvmodel.py", line 97, in init self.model, = clip.load("ViT-B/32", jit=False, device='cpu') File "/root/.local/lib/python3.9/site-packages/vision_aided_loss/CLIP/clip/clip.py", line 118, in load model_path = _download(_MODELS[name], download_root or os.path.expanduser("~/.cache/clip")) File "/root/.local/lib/python3.9/site-packages/vision_aided_loss/CLIP/clip/clip.py", line 57, in _download with urllib.request.urlopen(url) as source, open(download_target, "wb") as output: File "/root/.local/conda/envs/stylegan3/lib/python3.9/urllib/request.py", line 214, in urlopen return opener.open(url, data, timeout) File "/root/.local/conda/envs/stylegan3/lib/python3.9/urllib/request.py", line 517, in open response = self._open(req, data) File "/root/.local/conda/envs/stylegan3/lib/python3.9/urllib/request.py", line 534, in _open result = self._call_chain(self.handle_open, protocol, protocol + File "/root/.local/conda/envs/stylegan3/lib/python3.9/urllib/request.py", line 494, in _call_chain result = func(*args) File "/root/.local/conda/envs/stylegan3/lib/python3.9/urllib/request.py", line 1389, in https_open return self.do_open(http.client.HTTPSConnection, req, File "/root/.local/conda/envs/stylegan3/lib/python3.9/urllib/request.py", line 1349, in do_open raise URLError(err) urllib.error.URLError: <urlopen error Tunnel connection failed: 403 Forbidden>

How to solve this problem???>_<

nupurkmr9 commented 2 years ago

Hi,

Thanks for the interest in our work. I am not facing this issue consistently but faced it only once. Thus, it might be related to the number of requests made to the CLIP repo at any point of time.

If you are still facing this issue, one solution is to install CLIP using pip install git+https://github.com/openai/CLIP.git and try the below command repeatedly to save the ViT-B/32 model at ~HOME/.cache/clip/ViT-B-32.pt.

import clip
model, preprocess = clip.load("ViT-B/32", device='cpu')

Sorry for the delayed response. Hope this helps.