Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
d240a8d
Some progress
p-wysocki May 29, 2023
a61e4fd
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki May 29, 2023
6df4246
refactoring
p-wysocki May 29, 2023
811b717
Refactor tests, run black
p-wysocki May 30, 2023
0e1d2c3
Refactor, flake
p-wysocki May 30, 2023
b195136
Minor change
p-wysocki May 30, 2023
4d6e45a
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki May 31, 2023
15a982a
Add support for num_output_channels
p-wysocki May 31, 2023
0ed3009
WIP
p-wysocki Jun 5, 2023
de5db58
Add dependency
p-wysocki Jun 5, 2023
c12ce3b
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jun 5, 2023
619369d
Almost done
p-wysocki Jun 7, 2023
3bd7042
Fix flake
p-wysocki Jun 7, 2023
27f11f9
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jun 12, 2023
a2216c6
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jun 12, 2023
e405609
Add MO convert
p-wysocki Jun 12, 2023
3da5fb9
Minor changes
p-wysocki Jun 12, 2023
5763154
Add interpolation mode tests
p-wysocki Jun 12, 2023
773594b
Add requirements for preprocessing
p-wysocki Jun 12, 2023
33ae1f9
Fix linter
p-wysocki Jun 13, 2023
6a33f98
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jun 13, 2023
573f584
Update tests
p-wysocki Jun 13, 2023
222aa77
Fix type error
p-wysocki Jun 13, 2023
58a0e12
Introduce typing
p-wysocki Jun 13, 2023
47f2dc5
Rename module
p-wysocki Jun 13, 2023
01f5316
Code review
p-wysocki Jun 13, 2023
76fcf85
Update src/bindings/python/src/openvino/preprocess/torchvision/torchv…
p-wysocki Jun 14, 2023
1aa5253
Update src/bindings/python/src/openvino/preprocess/torchvision/prepro…
p-wysocki Jun 14, 2023
dda68d5
CR changes
p-wysocki Jun 19, 2023
a55e266
Merge branch 'torchvision' of https://github.com/p-wysocki/openvino i…
p-wysocki Jun 19, 2023
44493b1
Fix mypy
p-wysocki Jun 19, 2023
8e9e672
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jun 19, 2023
1eccc3a
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jun 23, 2023
c169a48
Minor change
p-wysocki Jun 23, 2023
ee82609
Minor change
p-wysocki Jun 28, 2023
a8bb100
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jun 28, 2023
558f477
Fix flake
p-wysocki Jun 28, 2023
6480641
typing change
p-wysocki Jun 29, 2023
5f95a8a
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jun 29, 2023
bdd0036
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jun 30, 2023
8dc9016
Update types
p-wysocki Jun 30, 2023
6c66d54
Add tools to pythonpath
p-wysocki Jun 30, 2023
2de8db2
Add MO reqs
p-wysocki Jun 30, 2023
2eb076e
Minor change
p-wysocki Jun 30, 2023
4cee9ac
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jul 3, 2023
f2fd9a5
Fix PT FE issue
p-wysocki Jul 3, 2023
42d8957
bugfix
p-wysocki Jul 3, 2023
974195b
Use absolute path
p-wysocki Jul 3, 2023
c1ad612
Debug
p-wysocki Jul 3, 2023
d7242b1
Debug req path
p-wysocki Jul 3, 2023
c23d84a
Change MO to OVC
p-wysocki Jul 3, 2023
c43eca1
Enable PT FE building
p-wysocki Jul 3, 2023
8e2b710
Debug
p-wysocki Jul 3, 2023
a172f55
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jul 4, 2023
5506bdb
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jul 7, 2023
09e63d9
Skip some tests on ARM
p-wysocki Jul 7, 2023
8cd6352
ADd ticket numbers
p-wysocki Jul 7, 2023
f6b6f20
Some progress
p-wysocki May 29, 2023
37cd7e9
refactoring
p-wysocki May 29, 2023
d7e8fe5
Refactor tests, run black
p-wysocki May 30, 2023
610abab
Refactor, flake
p-wysocki May 30, 2023
e29a5f8
Minor change
p-wysocki May 30, 2023
f344b99
Add support for num_output_channels
p-wysocki May 31, 2023
04495dd
WIP
p-wysocki Jun 5, 2023
9d058c4
Add dependency
p-wysocki Jun 5, 2023
02d06d5
Almost done
p-wysocki Jun 7, 2023
de9a992
Fix flake
p-wysocki Jun 7, 2023
f4b3242
Add MO convert
p-wysocki Jun 12, 2023
ed0d39d
Minor changes
p-wysocki Jun 12, 2023
d5ade9b
Add interpolation mode tests
p-wysocki Jun 12, 2023
b4dc4c2
Add requirements for preprocessing
p-wysocki Jun 12, 2023
c4d8f66
Fix linter
p-wysocki Jun 13, 2023
2bc333a
Update tests
p-wysocki Jun 13, 2023
c630e04
Fix type error
p-wysocki Jun 13, 2023
6107d3c
Introduce typing
p-wysocki Jun 13, 2023
648b17e
Rename module
p-wysocki Jun 13, 2023
19c42c9
Code review
p-wysocki Jun 13, 2023
b7c295f
Update src/bindings/python/src/openvino/preprocess/torchvision/torchv…
p-wysocki Jun 14, 2023
ff42525
Update src/bindings/python/src/openvino/preprocess/torchvision/prepro…
p-wysocki Jun 14, 2023
baac042
CR changes
p-wysocki Jun 19, 2023
82d6f6f
Fix mypy
p-wysocki Jun 19, 2023
5375ac5
Minor change
p-wysocki Jun 23, 2023
e6bc959
Minor change
p-wysocki Jun 28, 2023
48e423e
Fix flake
p-wysocki Jun 28, 2023
0823c71
typing change
p-wysocki Jun 29, 2023
771b250
Update types
p-wysocki Jun 30, 2023
ea05a11
Add tools to pythonpath
p-wysocki Jun 30, 2023
d528487
Add MO reqs
p-wysocki Jun 30, 2023
48c9cc5
Minor change
p-wysocki Jun 30, 2023
3c9eaa0
Fix PT FE issue
p-wysocki Jul 3, 2023
5ae4b0e
bugfix
p-wysocki Jul 3, 2023
1c906f4
Use absolute path
p-wysocki Jul 3, 2023
6f36994
Debug
p-wysocki Jul 3, 2023
3f6e8a3
Debug req path
p-wysocki Jul 3, 2023
e0a1864
Change MO to OVC
p-wysocki Jul 3, 2023
ca8672e
Enable PT FE building
p-wysocki Jul 3, 2023
44eb246
Debug
p-wysocki Jul 3, 2023
caa358b
Skip some tests on ARM
p-wysocki Jul 7, 2023
10aef53
ADd ticket numbers
p-wysocki Jul 7, 2023
4c21379
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jul 11, 2023
8211a12
Update test val
p-wysocki Jul 11, 2023
76db424
Merge branch 'torchvision' of https://github.com/p-wysocki/openvino i…
p-wysocki Jul 11, 2023
2dbe0b1
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jul 12, 2023
96a7afb
Change pytest version
p-wysocki Jul 12, 2023
b73a33f
Modify GH workflow
p-wysocki Jul 14, 2023
91f0bfb
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jul 14, 2023
bf46f5f
Merge branch 'master' into torchvision
p-wysocki Jul 17, 2023
e4e4583
Merge branch 'master' into torchvision
gklodkox Jul 17, 2023
65ed658
Merge branch 'master' into torchvision
gklodkox Jul 18, 2023
c7d2ab4
Merge branch 'master' into torchvision
p-wysocki Jul 18, 2023
43e2cd6
Update cmake
p-wysocki Jul 18, 2023
0fd318a
Merge branch 'torchvision' of https://github.com/p-wysocki/openvino i…
p-wysocki Jul 18, 2023
ef8c2d6
Merge branch 'master' into torchvision
gklodkox Jul 18, 2023
93860ea
Merge branch 'master' into torchvision
mlukasze Jul 19, 2023
44318c6
Merge branch 'master' into torchvision
gklodkox Jul 19, 2023
c0a6740
Update cmake
p-wysocki Jul 19, 2023
d9e787b
Merge branch 'torchvision' of https://github.com/p-wysocki/openvino i…
p-wysocki Jul 19, 2023
faac50d
fix cmake
p-wysocki Jul 19, 2023
966f3c5
Merge branch 'master' into torchvision
gklodkox Jul 19, 2023
c401e7d
Merge branch 'master' into torchvision
mlukasze Jul 21, 2023
aa559bc
Merge branch 'master' into torchvision
gklodkox Jul 21, 2023
a9249fa
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jul 21, 2023
0e90d1b
Skip tests on ARM
p-wysocki Jul 21, 2023
8cb423b
Fix after OVC MO changes
p-wysocki Jul 21, 2023
c013e53
Merge branch 'master' into torchvision
gklodkox Jul 24, 2023
e898cd8
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jul 24, 2023
b2aaa6c
Limit torch requirements
p-wysocki Jul 24, 2023
5394d7c
Merge branch 'master' into torchvision
gklodkox Jul 24, 2023
4d69057
Merge branch 'master' into torchvision
gklodkox Jul 25, 2023
ba4cdd9
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jul 25, 2023
de792fb
Raise allowed diff in test
p-wysocki Jul 25, 2023
0cc25ed
Merge branch 'master' into torchvision
gklodkox Jul 25, 2023
8875f5d
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jul 26, 2023
bfee9ca
Merge branch 'torchvision' of https://github.com/p-wysocki/openvino i…
p-wysocki Jul 26, 2023
3b63fb3
Merge branch 'master' into torchvision
gklodkox Jul 27, 2023
6baf7d5
Debug - remove new bindings
p-wysocki Jul 28, 2023
3ff2b98
Merge remote-tracking branch 'upstream/master' into torchvision
p-wysocki Jul 28, 2023
1ad8cd6
Debug - remove interpolation modes
p-wysocki Jul 28, 2023
1dbf4bd
Debug - change test
p-wysocki Jul 28, 2023
e54e1cf
Cleanup
p-wysocki Jul 28, 2023
f0e8ddc
Minor change
p-wysocki Jul 28, 2023
3dbb6f1
Merge branch 'master' into torchvision
p-wysocki Jul 31, 2023
c453108
Disable on ARM and Py<38
p-wysocki Jul 31, 2023
be343b8
Update ARM marker
p-wysocki Jul 31, 2023
43870d9
limit torchvision for ARM
p-wysocki Jul 31, 2023
b51c825
Merge branch 'master' into torchvision
p-wysocki Aug 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .ci/azure/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ jobs:
python3 -m pip install -r $(REPO_DIR)/src/frontends/onnx/tests/requirements.txt
# For running TensorFlow frontend unit tests
python3 -m pip install -r $(REPO_DIR)/src/frontends/tensorflow/tests/requirements.txt
# For running torchvision -> OpenVINO preprocess converter
python3 -m pip install -r $(REPO_DIR)/src/bindings/python/src/openvino/preprocess/torchvision/requirements.txt
# For MO unit tests
python3 -m pip install -r $(REPO_DIR)/tools/mo/requirements_mxnet.txt
python3 -m pip install -r $(REPO_DIR)/tools/mo/requirements_caffe.txt
Expand Down
4 changes: 2 additions & 2 deletions .ci/openvino-onnx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ RUN cmake .. \
-DENABLE_PROFILING_ITT=OFF \
-DENABLE_SAMPLES=OFF \
-DENABLE_OV_PADDLE_FRONTEND=OFF \
-DENABLE_OV_PYTORCH_FRONTEND=OFF \
-DENABLE_OV_PYTORCH_FRONTEND=ON \
-DENABLE_OV_TF_FRONTEND=OFF \
-DENABLE_OPENVINO_DEBUG=OFF \
-DCMAKE_INSTALL_PREFIX=/openvino/dist
Expand All @@ -72,5 +72,5 @@ RUN ninja install
WORKDIR /openvino/src/bindings/python
ENV OpenVINO_DIR=/openvino/dist/runtime/cmake
ENV LD_LIBRARY_PATH=/openvino/dist/runtime/lib/intel64:/openvino/dist/runtime/3rdparty/tbb/lib
ENV PYTHONPATH=/openvino/bin/intel64/${BUILD_TYPE}/python:${PYTHONPATH}
ENV PYTHONPATH=/openvino/bin/intel64/${BUILD_TYPE}/python:/openvino/tools/mo:${PYTHONPATH}
CMD tox
3 changes: 3 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,9 @@ jobs:
# For running Paddle frontend unit tests
python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/frontends/paddle/tests/requirements.txt

# For torchvision to OpenVINO preprocessing converter
python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/bindings/python/src/openvino/preprocess/torchvision/requirements.txt

- name: Install MO dependencies
run: |
python3 -m pip install -r ${{ env.OPENVINO_REPO }}/tools/mo/requirements_mxnet.txt
Expand Down
8 changes: 6 additions & 2 deletions src/bindings/python/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ numpy>=1.16.6,<1.26 # Python bindings, frontends
# pytest
pytest>=5.0,<7.4
pytest-dependency==0.5.1
pytest-html==3.1.1
pytest-html==3.2.0
pytest-timeout==2.1.0

# Python bindings
Expand All @@ -19,4 +19,8 @@ paddlepaddle==2.4.2
tensorflow>=1.15.5,<2.13.0
six~=1.16.0
protobuf>=3.18.1,<4.0.0
onnx==1.13.1
onnx==1.13.1

# torchvision > OpenVINO preprocessing converter
pillow>=9.0
torch>=1.13
4 changes: 4 additions & 0 deletions src/bindings/python/requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ tox
types-pkg_resources
wheel
singledispatchmethod
torch
torchvision; platform_machine == 'arm64' and python_version >= '3.8'
torchvision; platform_machine != 'arm64'
pillow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it's better to test via tox.ini files, where we can run different categories of tests in different environments.
Currently, we are adding more and more to our requirements.txt files and it complicates future support because of conflicting dependencies.

I'm not suggesting to change the approach in this specific PR, but rather a general consideration - drop requirements.txt for tests and rely only on tox.ini files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a good idea, let's continue it in 115462.

3 changes: 3 additions & 0 deletions src/bindings/python/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ skip_install=True
deps =
-rrequirements.txt
-rrequirements_test.txt
-r /openvino/tools/mo/requirements.txt # for torchvision -> OV preprocess converter
-r /openvino/src/frontends/onnx/tests/requirements.txt
setenv =
OV_BACKEND = {env:OV_BACKEND:"CPU"}
Expand Down Expand Up @@ -43,6 +44,7 @@ deps = -rrequirements.txt
# D107 - Missing docstring in __init__
# D412 - No blank lines allowed between a section header and its content
# F401 - module imported but unused
# N801 - class name '...' should use CapWords convention
# N803 - argument name '...' should be lowercase
# T001 - print found
# W503 - line break before binary operator (prefer line breaks before op, not after)
Expand All @@ -66,6 +68,7 @@ per-file-ignores =
src/openvino/runtime/*/ops.py: VNE001,VNE003
tests_compatibility/test_ngraph/*: C101,C812,C815,C816,C819,CCE001,D212,E800,ECE001,N400,N802,N806,P101,P103,PT001,PT005,PT006,PT011,PT019,PT023,RST201,S001,VNE002
src/compatibility/ngraph/*: C101,C812,C819,CCE001,E800,N806,P101,RST201,RST202,RST203,RST206,VNE001,VNE003
src/openvino/preprocess/torchvision/*: N801, VNE001
*__init__.py: F401

[pydocstyle]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

"""
Package: openvino
Torchvision to OpenVINO preprocess converter.
"""

# flake8: noqa

from openvino._pyopenvino import get_version as _get_version

__version__ = _get_version()

from .preprocess_converter import PreprocessConverter
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

from typing import Callable, Any, Union
import logging

import openvino.runtime as ov


class PreprocessConverter():
def __init__(self, model: ov.Model):
self._model = model

@staticmethod
def from_torchvision(model: ov.Model, transform: Callable, input_example: Any,
input_name: Union[str, None] = None) -> ov.Model:
"""Embed torchvision preprocessing in an OpenVINO model.

Arguments:
model (ov.Model):
Result name
transform (Callable):
torchvision transform to convert
input_example (torch.Tensor or np.ndarray or PIL.Image):
Example of input data for transform to trace its structure.
Don't confuse with the model input.
input_name (str, optional):
Name of the current model's input node to connect with preprocessing.
Not needed if the model has one input.

Returns:
ov.Mode: OpenVINO Model object with embedded preprocessing
Example:
>>> model = PreprocessorConvertor.from_torchvision(model, "input", transform, input_example)
"""
try:
import PIL
import torch
from torchvision import transforms
from .torchvision_preprocessing import _from_torchvision
return _from_torchvision(model, transform, input_example, input_name)
except ImportError as e:
raise ImportError(f"Please install torch, torchvision and pillow packages:\n{e}")
except Exception as e:
logging.error(f"Unexpected error: {e}")
raise e
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-c ../../../../constraints.txt
torch
torchvision; platform_machine == 'arm64' and python_version >= '3.8'
torchvision; platform_machine != 'arm64'
pillow
Loading