GaParmar / clean-fid

PyTorch - FID calculation with proper image resizing and quantization steps [CVPR 2022]
https://www.cs.cmu.edu/~clean-fid/
MIT License
894 stars 68 forks source link

HTTPError: HTTP Error 404: Not Found #56

Open Mao718 opened 5 months ago

Mao718 commented 5 months ago

I tried fid.compute_fid function with cifar10 dataset. It went perfectly until last week. Seem like the dataset's URL is no longer supported. Does anyone have the same error as me?

compute FID of a folder with cifar10 statistics downloading statistics to /usr/local/lib/python3.10/dist-packages/cleanfid/stats/cifar10_clean_train_1024.npz

HTTPError Traceback (most recent call last) in <cell line: 1>() ----> 1 score_clean = fid.compute_fid("folder_real", dataset_name="cifar10") 2 print(f"clean-fid score is {score_clean:.3f}")

9 frames /usr/local/lib/python3.10/dist-packages/cleanfid/fid.py in compute_fid(fdir1, fdir2, gen, mode, model_name, num_workers, batch_size, device, dataset_name, dataset_res, dataset_split, num_gen, z_dim, custom_feat_extractor, verbose, custom_image_tranform, custom_fn_resize, use_dataparallel) 488 if verbose: 489 print(f"compute FID of a folder with {dataset_name} statistics") --> 490 score = fid_folder(fdir1, dataset_name, dataset_res, dataset_split, 491 model=feat_model, mode=mode, model_name=model_name, 492 custom_fn_resize=custom_fn_resize, custom_image_tranform=custom_image_tranform,

/usr/local/lib/python3.10/dist-packages/cleanfid/fid.py in fid_folder(fdir, dataset_name, dataset_res, dataset_split, model, mode, model_name, num_workers, batch_size, device, verbose, custom_image_tranform, custom_fn_resize) 171 custom_image_tranform=None, custom_fn_resize=None): 172 # Load reference FID statistics (download if needed) --> 173 ref_mu, ref_sigma = get_reference_statistics(dataset_name, dataset_res, 174 mode=mode, model_name=model_name, seed=0, split=dataset_split) 175 fbname = os.path.basename(fdir)

/usr/local/lib/python3.10/dist-packages/cleanfid/features.py in get_reference_statistics(name, res, mode, model_name, seed, split, metric) 64 mod_path = os.path.dirname(cleanfid.file) 65 stats_folder = os.path.join(mod_path, "stats") ---> 66 fpath = check_download_url(local_folder=stats_folder, url=url) 67 stats = np.load(fpath) 68 mu, sigma = stats["mu"], stats["sigma"]

/usr/local/lib/python3.10/dist-packages/cleanfid/downloads_helper.py in check_download_url(local_folder, url) 34 os.makedirs(local_folder, exist_ok=True) 35 print(f"downloading statistics to {local_path}") ---> 36 with urllib.request.urlopen(url) as response, open(local_path, 'wb') as f: 37 shutil.copyfileobj(response, f) 38 return local_path

/usr/lib/python3.10/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context) 214 else: 215 opener = _opener --> 216 return opener.open(url, data, timeout) 217 218 def install_opener(opener):

/usr/lib/python3.10/urllib/request.py in open(self, fullurl, data, timeout) 523 for processor in self.process_response.get(protocol, []): 524 meth = getattr(processor, meth_name) --> 525 response = meth(req, response) 526 527 return response

/usr/lib/python3.10/urllib/request.py in http_response(self, request, response) 632 # request was successfully received, understood, and accepted. 633 if not (200 <= code < 300): --> 634 response = self.parent.error( 635 'http', request, response, code, msg, hdrs) 636

/usr/lib/python3.10/urllib/request.py in error(self, proto, args) 561 if http_err: 562 args = (dict, 'default', 'http_error_default') + orig_args --> 563 return self._call_chain(args) 564 565 # XXX probably also want an abstract factory that knows when it makes

/usr/lib/python3.10/urllib/request.py in _call_chain(self, chain, kind, meth_name, args) 494 for handler in handlers: 495 func = getattr(handler, meth_name) --> 496 result = func(args) 497 if result is not None: 498 return result

/usr/lib/python3.10/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs) 641 class HTTPDefaultErrorHandler(BaseHandler): 642 def http_error_default(self, req, fp, code, msg, hdrs): --> 643 raise HTTPError(req.full_url, code, msg, hdrs, fp) 644 645 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 404: Not Found

Mao718 commented 5 months ago

Sorry, I figure out the reason.

The file is there. Setting up the resolution can fix this problem dataset_res=32.