-
-
Notifications
You must be signed in to change notification settings - Fork 16.5k
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
Replace os.system('unzip file.zip')
-> ZipFile.extractall()
#4919
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@kalenmike this will likely conflict with your open PR #4774, but also helps remove os.system() calls as you'd recommended earlier, and fixes some immediate Windows issues in #4779. |
glenn-jocher
added a commit
that referenced
this pull request
Sep 25, 2021
Fix for bug introduced by #4919 discovered on VOC autodownload: ``` python train.py --data VOC.yaml ```
glenn-jocher
added a commit
that referenced
this pull request
Sep 25, 2021
Before and After profiling results show slightly improved speeds :) import os
import time
from pathlib import Path
from zipfile import ZipFile
file = Path('test/coco2017labels.zip')
t = time.time()
ZipFile(file).extractall(path=file.parent)
print(f'DONE PYTHON in {time.time() - t}s')
t = time.time()
os.system(f'unzip -qo {file} -d {file.parent}')
print(f'DONE BASH in {time.time() - t}s') Returns DONE PYTHON in 26.95448899269104s
DONE BASH in 31.251495122909546s |
Closed
CesarBazanAV
pushed a commit
to CesarBazanAV/yolov5
that referenced
this pull request
Sep 29, 2021
…alytics#4919) * Replace `os.system('unzip file.zip')` -> `ZipFile.extractall()` * Cleanup
CesarBazanAV
pushed a commit
to CesarBazanAV/yolov5
that referenced
this pull request
Sep 29, 2021
* Fix `root` referenced before assignment Fix for bug introduced by ultralytics#4919 discovered on VOC autodownload: ``` python train.py --data VOC.yaml ``` * Cleanup
Merged
BjarneKuehl
pushed a commit
to fhkiel-mlaip/yolov5
that referenced
this pull request
Aug 26, 2022
…alytics#4919) * Replace `os.system('unzip file.zip')` -> `ZipFile.extractall()` * Cleanup
BjarneKuehl
pushed a commit
to fhkiel-mlaip/yolov5
that referenced
this pull request
Aug 26, 2022
* Fix `root` referenced before assignment Fix for bug introduced by ultralytics#4919 discovered on VOC autodownload: ``` python train.py --data VOC.yaml ``` * Cleanup
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates all YOLOv5 unzip ops from os.system() commands, which appear to cause Windows issues in a small number of cases, with the python built-in
zipfile
package, which should provide greater compatibility across operating systems.🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Refactoring of zip file extraction methods across multiple utility scripts.
📊 Key Changes
os.system
unzip calls withZipFile.extractall
method indatasets.py
,downloads.py
, andgeneral.py
.🎯 Purpose & Impact
ZipFile
module instead of system commands, code becomes more secure and works across all operating systems without relying on external unzip utilities.