This repository has been archived by the owner on May 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reference kit update to AI Kit 2024.0.0 compatible components (#1) (#2)
* Reference kit update to AI Kit 2024.0.0 compatible components (#1) * Remove stock environment. * Remove env/intel directory. * Add intel_env.yml file * Add .gitignore * Delete stock-pipeline.png * Move VOC.yaml to config directory. * Remove training.patch * Add new training.patch * Add output dir to .gitignore * Move deploy.yaml to config directory. * Add src/yolov5 to .gitignore * Remove stock part of code from run_inference.py. * Remove inference.png * Delete ThroughputOpenVinoQuantizationBenchmark.png * Update intel_env.yml. -Add ultralytics, gitpython * Remove data.txt * Update README.md * Update run_inference.py -Changed int8inc and save_image args to store_true * Add log info to openvino_quantization.py * Fix logger in openvino_quantization.py -Logger wasn't showing information at INFO level. * Add log notifications to openvino_quantization.py -Add 'This will take time, please wait!' message before create pipeline and execute pipeline. * Add sections to README.md. - Add validation tags. - Add Expected Output. - Add Disclaimer. - Modify style. * Fix README.md typos and style. * Update .gitignore * Update README.md - Correct typos. - Correct styles. - Add rm instruction. * Update README.md - Correct typos. - Correct styles. * Update README.md - Remove text referencing a non-existing codeblock. * Update README.md - Give uniform style to Notes. * Update README.md - Change WORKSPACE dir name. - Change . for $WORKSPACE in git command. * Remove traffic-detection submodule * Update intel_env.yml - Remove ipython from environment. * Fix typos in README.md * Fix dataset dir structure in README.md * Added curl install instruction to README.md
- Loading branch information
Showing
14 changed files
with
689 additions
and
498 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
data/ | ||
output/ | ||
src/yolov5/ |
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,51 @@ | ||
diff --git a/train.py b/train.py | ||
index 177e081..9b42fe9 100644 | ||
index 4c3bec3..a82fbfb 100644 | ||
--- a/train.py | ||
+++ b/train.py | ||
@@ -239,6 +239,16 @@ def train(hyp, opt, device, callbacks): # hyp is path/to/hyp.yaml or hyp dictio | ||
@@ -24,6 +24,7 @@ import sys | ||
import time | ||
from copy import deepcopy | ||
from datetime import datetime, timedelta | ||
+import intel_extension_for_pytorch as ipex | ||
from pathlib import Path | ||
|
||
try: | ||
@@ -249,6 +250,14 @@ def train(hyp, opt, device, callbacks): # hyp is path/to/hyp.yaml or hyp dictio | ||
model.class_weights = labels_to_class_weights(dataset.labels, nc).to(device) * nc # attach class weights | ||
model.names = names | ||
|
||
+ # Ipex Optimizing Model | ||
+ if opt.intel or opt.bf16: | ||
+ import intel_extension_for_pytorch as ipex | ||
+ model.model.to(memory_format=torch.channels_last) | ||
+ if opt.bf16: | ||
+ model, optimizer = ipex.optimize(model, optimizer=optimizer, dtype=torch.bfloat16) | ||
+ else: | ||
+ model, optimizer = ipex.optimize(model, optimizer=optimizer) | ||
+ print("IPEX optimization enabled") | ||
+ model.model.to(memory_format=torch.channels_last) | ||
+ if opt.bf16: | ||
+ model, optimizer = ipex.optimize(model, optimizer=optimizer, dtype=torch.bfloat16) | ||
+ else: | ||
+ model, optimizer = ipex.optimize(model, optimizer=optimizer) | ||
+ print("IPEX optimization enabled") | ||
+ | ||
# Start training | ||
t0 = time.time() | ||
nb = len(train_loader) # number of batches | ||
@@ -281,7 +291,11 @@ def train(hyp, opt, device, callbacks): # hyp is path/to/hyp.yaml or hyp dictio | ||
@@ -291,7 +300,10 @@ def train(hyp, opt, device, callbacks): # hyp is path/to/hyp.yaml or hyp dictio | ||
for i, (imgs, targets, paths, _) in pbar: # batch ------------------------------------------------------------- | ||
callbacks.run('on_train_batch_start') | ||
ni = i + nb * epoch # number integrated batches (since train start) | ||
- imgs = imgs.to(device, non_blocking=True).float() / 255 # uint8 to float32, 0-255 to 0.0-1.0 | ||
+ | ||
+ if opt.bf16: | ||
+ imgs = imgs.to(device, non_blocking=True).bfloat16() / 255 # uint8 to float16, 0-255 to 0.0-1.0 | ||
+ else: | ||
+ imgs = imgs.to(device, non_blocking=True).float() / 255 # uint8 to float32, 0-255 to 0.0-1.0 | ||
|
||
# Warmup | ||
if ni <= nw: | ||
@@ -472,6 +486,11 @@ def parse_opt(known=False): | ||
@@ -481,6 +493,8 @@ def parse_opt(known=False): | ||
parser.add_argument('--upload_dataset', nargs='?', const=True, default=False, help='Upload data, "val" option') | ||
parser.add_argument('--bbox_interval', type=int, default=-1, help='Set bounding-box image logging interval') | ||
parser.add_argument('--artifact_alias', type=str, default='latest', help='Version of dataset artifact to use') | ||
|
||
+ # Intel Ipex Optimization | ||
+ parser.add_argument('--intel', '-i', type=int, default=0, help='To Enable Intel Optimization set to 1, default 0') | ||
+ # Intel Ipex Optimization BF16 | ||
+ parser.add_argument('--bf16', action='store_true', help='Enable only on Intel® Fourth Gen Xeon, BF16') | ||
+ | ||
return parser.parse_known_args()[0] if known else parser.parse_args() | ||
|
||
return parser.parse_known_args()[0] if known else parser.parse_args() | ||
|
||
-- | ||
2.34.1 | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: traffic_detection_intel | ||
channels: | ||
- intel | ||
- conda-forge | ||
dependencies: | ||
- python=3.9 | ||
- opencv=4.8.0 | ||
- intel-aikit-pytorch=2024.0 | ||
- neural-compressor=2.3.1 | ||
- torchvision=0.15.2 | ||
- seaborn=0.13.0 | ||
- tqdm=4.66.1 | ||
- tensorboard=2.15.1 | ||
- pillow=10.0.1 | ||
- ultralytics=8.0.227 | ||
- gitpython=3.1.40 | ||
- pip=23.3.1 | ||
- pip: | ||
- opencv-python-headless==4.8.1.78 | ||
- thop==0.1.1-2209072238 | ||
- openvino-dev[pytorch,onnx]==2023.2.0 | ||
- onnx==1.14.1 |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.