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

PermissionError during creating the folders for downloaded weights data #1

Open
jakobkrieger opened this issue Sep 11, 2021 · 1 comment

Comments

@jakobkrieger
Copy link

jakobkrieger commented Sep 11, 2021

Hi,

when I first tried out the package, I got always following exception

Traceback (most recent call last):
  File "/usr/lib/python3.8/pathlib.py", line 1288, in mkdir
    self._accessor.mkdir(self, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/.lwcc/weights'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./crowd_counting.py", line 53, in <module>
    results = count(args.img_path)
  File "./crowd_counting.py", line 38, in count
    count, density = LWCC.get_count(
  File "/home/jmkrieger/.local/lib/python3.8/site-packages/lwcc/LWCC.py", line 65, in get_count
    model = load_model(model_name, model_weights)
  File "/home/jmkrieger/.local/lib/python3.8/site-packages/lwcc/LWCC.py", line 31, in load_model
    model = model.make_model(model_weights)
  File "/home/jmkrieger/.local/lib/python3.8/site-packages/lwcc/models/CSRNet.py", line 13, in make_model
    output = weights_check("CSRNet", model_weights)
  File "/home/jmkrieger/.local/lib/python3.8/site-packages/lwcc/util/functions.py", line 17, in weights_check
    Path("/.lwcc/weights").mkdir(parents=True, exist_ok=True)
  File "/usr/lib/python3.8/pathlib.py", line 1292, in mkdir
    self.parent.mkdir(parents=True, exist_ok=True)
  File "/usr/lib/python3.8/pathlib.py", line 1288, in mkdir
    self._accessor.mkdir(self, mode)
PermissionError: [Errno 13] Permission denied: '/.lwcc'

I traced the error and found that the function weights_check in lwcc/util/functions.py tried to create the folder designated for the downloaded weights in the root folder, and not the home directory.

I could easily fixed it for me by changing the function to

def weights_check(model_name, model_weights):
    home = str(Path.home())

    # create dir if does not exists
    Path(os.path.join(home, ".lwcc/weights")).mkdir(parents=True, exist_ok=True)

    # download weights if not available
    file_name = "{}_{}.pth".format(model_name, model_weights)
    url = build_url(file_name)
    output = os.path.join(home, ".lwcc/weights/", file_name)
    # [...]

Thank you for creating this package - it's quite mindblowing what today's neural networks can achieve!

@tersekmatija
Copy link
Owner

Hey @jakobkrieger !

Thank you for your feedback, and I'm glad that you managed to resolve the issue. We'll push this fix in the next update together with the GPU support.

Thank you for creating this package - it's quite mindblowing what today's neural networks can achieve!

No problem, and I agree with you. I hope you will find this package useful! :)

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

2 participants