Open Roman-Rudensky opened 1 year ago
π Hello @Roman-Rudensky, thank you for leaving an issue on Roboflow Notebooks.
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.
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.
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
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)
Search before asking
Notebook name
zero-shot-object-detection-with-grounding-dino.ipynb
Bug
Environment
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:
83 shutil.copyfile(filename, osp.join(temp_config_dir, temp_config_name))
Are you willing to submit a PR?