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

Issue with load_model on Windows platform #97

Open
1 of 2 tasks
Roman-Rudensky opened this issue Apr 7, 2023 · 3 comments
Open
1 of 2 tasks

Issue with load_model on Windows platform #97

Roman-Rudensky opened this issue Apr 7, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@Roman-Rudensky
Copy link

Search before asking

  • I have searched the Roboflow Notebooks issues and found no similar bug report.

Notebook name

zero-shot-object-detection-with-grounding-dino.ipynb

Bug

image

Environment

  • Local
  • OS Windows10

Minimal Reproducible Example

No response

Additional

The issue happens because shutil.copyfile() attempts to open tempfile which is already opened. On Windows platform this raises Permission Error.
Here's how I could solve that in slconfig.py (lines 80-83):
80 with tempfile.TemporaryDirectory() as temp_config_dir:
81 temp_config_file = tempfile.NamedTemporaryFile(dir=temp_config_dir, suffix=".py") # here temp_config_file is opened
82 temp_config_name = osp.basename(temp_config_file.name)
# on Windows attempt to open temp_config_file by shutil raises IOError: [Errno 13] Permission denied:
# close file before using shutil
temp_config_file.close()
83 shutil.copyfile(filename, osp.join(temp_config_dir, temp_config_name))

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@Roman-Rudensky Roman-Rudensky added the bug Something isn't working label Apr 7, 2023
@github-actions
Copy link

github-actions bot commented Apr 7, 2023

👋 Hello @Roman-Rudensky, thank you for leaving an issue on Roboflow Notebooks.

🐞 Bug reports

If you are filing a bug report, please be as detailed as possible. This will help us more easily diagnose and resolve the problem you are facing. To learn more about contributing, check out our Contributing Guidelines.

If you require support with custom code that is not part of Roboflow Notebooks, please reach out on the Roboflow Forum or on the GitHub Discussions page associated with this repository.

💬 Get in touch

Do you have more questions about Roboflow that we haven't responded to yet? Feel free to ask them on the Roboflow Discuss forum. Our developer advocates and community team actively respond to questions there.

To ask questions about Notebooks, head over to the GitHub Discussions section of this repository.

@tzjtatata
Copy link

The bug is caused by different implement of tempfile between linux and windows.
The file is already opened but shutil.copyfile() will try to open it again causing the permission error -- the file is already locked.
So you should use delete=False when using NamedTemporaryFile near slconfig.py:86, and mannually close the tempfile near the code 'tempfile.close()' with os.unlink(...).
ref: https://stackoverflow.com/questions/23212435/permission-denied-to-write-to-my-temporary-file

@jacobpchen
Copy link

Leaving this here for others, I went to the slconfig.py file (located in GroundingDino/groundingdino/util/slconfig.py

and added delete=False to line 81

The line now reads: temp_config_file = tempfile.NamedTemporaryFile(dir=temp_config_dir, suffix=".py", delete=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants