Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils/storage.py error #2702

Open
MATEMATNKx opened this issue Dec 1, 2024 · 0 comments
Open

utils/storage.py error #2702

MATEMATNKx opened this issue Dec 1, 2024 · 0 comments

Comments

@MATEMATNKx
Copy link

https://github.com/deepinsight/insightface/blob/v0.7/python-package/insightface/utils/storage.py#L13

Error in line for Windows here

def download(sub_dir, name, force=False, root='~/.insightface'):
    _root = os.path.expanduser(root)
    dir_path = os.path.join(_root, sub_dir, name)
    if osp.exists(dir_path) and not force:
        return dir_path
    print('download_path:', dir_path)
    zip_file_path = os.path.join(_root, sub_dir, name + '.zip')
    model_url = "%s/%s/%s.zip"%(BASE_REPO_URL, sub_dir, name)
    #model_url = "%s/%s.zip"%(BASE_REPO_URL, name)
    download_file(model_url,
             path=zip_file_path,
             overwrite=True)
    if not os.path.exists(dir_path):
        os.makedirs(dir_path)
    with zipfile.ZipFile(zip_file_path) as zf:
        zf.extractall(dir_path)
    #os.remove(zip_file_path)
    return dir_path

def ensure_available(sub_dir, name, root='~/.insightface'):
    return download(sub_dir, name, force=False, root=root)

The issue
#1525 (comment)

You need change code to:

def download(sub_dir, name, force=False, root='~/.insightface'):
   _root = os.path.expanduser(root)
   extract_path = os.path.join(_root, sub_dir)
   dir_path = os.path.join(extract_path, name)
   if osp.exists(dir_path) and not force:
       return dir_path
   print('download_path:', dir_path)
   zip_file_path = os.path.join(_root, sub_dir, name + '.zip')
   model_url = "%s/%s.zip"%(BASE_REPO_URL, name)
   download_file(model_url,
            path=zip_file_path,
            overwrite=True)
   if not os.path.exists(dir_path):
       os.makedirs(dir_path)
   with zipfile.ZipFile(zip_file_path) as zf:
       zf.extractall(extract_path)
   #os.remove(zip_file_path)
   return dir_path
   ```
   with care, MATEMATNK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant