Skip to content

Commit

Permalink
test: download test fixtures differently (#140)
Browse files Browse the repository at this point in the history
* Retrieve OpenVINO test artifacts from https://download.01.org/
This change is a necessary precursor for removing the Git LFS support in
this repository and properly caching these artifacts in GitHub actions.
  • Loading branch information
abrown authored Oct 4, 2024
1 parent 72d7560 commit 2388a25
Show file tree
Hide file tree
Showing 33 changed files with 176 additions and 19,841 deletions.
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

11 changes: 7 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: true
lfs: true
- name: Checkout LFS objects
run: git lfs checkout
- uses: actions/[email protected]
with:
key: openvino-test-fixtures
path: |
crates/openvino/tests/fixtures/alexnet
crates/openvino/tests/fixtures/inception
crates/openvino/tests/fixtures/mobilenet
- uses: abrown/install-openvino-action@v8
with:
version: ${{ matrix.version }}
Expand Down Expand Up @@ -92,7 +96,6 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: true
lfs: true
- name: Build documentation
run: cargo doc --no-deps --features openvino-sys/runtime-linking

Expand Down
26 changes: 9 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,24 @@ crate (high-level, ergonomic bindings) for accessing OpenVINO™ functionality i
1. The [openvino-sys] crate creates bindings to the OpenVINO™ C API using `bindgen`; this requires a
local installation of `libclang`. Also, be sure to retrieve all Git submodules.

2. This repo currently uses [git-lfs](https://git-lfs.github.com/) for large file storage. If you
[install it](https://github.com/git-lfs/git-lfs/wiki/Installation) before cloning this
repository, it should have downloaded all large files. To check this, verify that `find
crates/openvino -name *.bin | xargs ls -lhr` returns `.bin` files of tens of megabytes. If not,
download the large files with:

```shell
git lfs fetch
git lfs checkout
```

3. This library binds to OpenVINO™'s shared libraries; how those native libraries are configured and
2. This library binds to OpenVINO™'s shared libraries; how those native libraries are configured and
installed on your system determines how these Rust bindings work. The [openvino-finder] crate
attempts to locate the necessary libraries and configuration; if you run into problems, you may
need to understand additional details documented in the [`openvino-finder`
docs][openvino-finder-docs].

[openvino-finder-docs]: https://docs.rs/openvino-finder

4. __For macOS (homebrew) users__. Install the openvino toolkit, which includes the native C library,
and set `DYLD_LIBRARY_PATH`:
3. During testing only, this library will download several models for its integration tests. This
relies on `curl` being available on the system path.

4. __For macOS (homebrew) users__. Install the openvino toolkit, which includes the native C
library, and set `DYLD_LIBRARY_PATH`:
```
brew install openvino
export DYLD_LIBRARY_PATH="$(brew --prefix)/lib"
brew install openvino
export DYLD_LIBRARY_PATH="$(brew --prefix)/lib"
```
Then you can build and run openvino-rs for [runtime linking](#build-for-runtime-linking).
Then you can build and run using [runtime linking](#build-for-runtime-linking).

### Build from an OpenVINO™ installation

Expand Down
13 changes: 7 additions & 6 deletions crates/openvino/tests/classify-alexnet.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
//! Demonstrates using `openvino-rs` to classify an image using an AlexNet model and a prepared input tensor. See
//! [README](fixtures/alexnet/README.md) for details on how this test fixture was prepared.
//! Demonstrates using `openvino` to classify an image using an AlexNet model and a prepared input
//! tensor.
mod fixtures;
mod util;

use anyhow::Ok;
use fixtures::alexnet::Fixture;
use fixtures::alexnet as fixture;
use openvino::{
prepostprocess, Core, DeviceType, ElementType, Layout, ResizeAlgorithm, Shape, Tensor,
};
Expand All @@ -15,16 +16,16 @@ use util::{Prediction, Predictions};
fn classify_alexnet() -> anyhow::Result<()> {
let mut core = Core::new()?;
let mut model = core.read_model_from_file(
&Fixture::graph().to_string_lossy(),
&Fixture::weights().to_string_lossy(),
&fixture::graph().to_string_lossy(),
&fixture::weights().to_string_lossy(),
)?;

let output_port = model.get_output_by_index(0)?;
assert_eq!(output_port.get_name()?, "prob");
assert_eq!(model.get_input_by_index(0)?.get_name()?, "data");

// Retrieve the tensor from the test fixtures.
let data = fs::read(Fixture::tensor())?;
let data = fs::read(fixture::tensor())?;
let input_shape = Shape::new(&[1, 227, 227, 3])?;
let element_type = ElementType::F32;
let mut tensor = Tensor::new(element_type, &input_shape)?;
Expand Down
13 changes: 7 additions & 6 deletions crates/openvino/tests/classify-inception.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
//! Demonstrates using `openvino-rs` to classify an image using an Inception SSD model and a prepared input tensor. See
//! [README](fixtures/inception/README.md) for details on how this test fixture was prepared.
//! Demonstrates using `openvino` to classify an image using an Inception SSD model and a prepared
//! input tensor.
mod fixtures;
mod util;

use anyhow::Ok;
use fixtures::inception::Fixture;
use fixtures::inception as fixture;
use openvino::{
prepostprocess, Core, DeviceType, ElementType, Layout, ResizeAlgorithm, Shape, Tensor,
};
Expand All @@ -15,16 +16,16 @@ use util::{Prediction, Predictions};
fn classify_inception() -> anyhow::Result<()> {
let mut core = Core::new()?;
let mut model = core.read_model_from_file(
&Fixture::graph().to_string_lossy(),
&Fixture::weights().to_string_lossy(),
&fixture::graph().to_string_lossy(),
&fixture::weights().to_string_lossy(),
)?;

let output_port = model.get_output_by_index(0)?;
assert_eq!(output_port.get_name()?, "InceptionV3/Predictions/Softmax");
assert_eq!(model.get_input_by_index(0)?.get_name()?, "input");

// Retrieve the tensor from the test fixtures.
let data = fs::read(Fixture::tensor())?;
let data = fs::read(fixture::tensor())?;
let input_shape = Shape::new(&[1, 299, 299, 3])?;
let element_type = ElementType::F32;
let mut tensor = Tensor::new(element_type, &input_shape)?;
Expand Down
14 changes: 7 additions & 7 deletions crates/openvino/tests/classify-mobilenet.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! Demonstrates using `openvino-rs` to classify an image using an MobileNet model and a prepared
//! input tensor. See [README](fixtures/inception/README.md) for details on how this test fixture
//! was prepared.
//! Demonstrates using `openvino` to classify an image using an MobileNet model and a prepared input
//! tensor.
mod fixtures;
mod util;

use fixtures::mobilenet::Fixture;
use fixtures::mobilenet as fixture;
use openvino::{
prepostprocess, Core, DeviceType, ElementType, Layout, ResizeAlgorithm, Shape, Tensor,
};
Expand All @@ -15,16 +15,16 @@ use util::{Prediction, Predictions};
fn classify_mobilenet() -> anyhow::Result<()> {
let mut core = Core::new()?;
let mut model = core.read_model_from_file(
&Fixture::graph().to_string_lossy(),
&Fixture::weights().to_string_lossy(),
&fixture::graph().to_string_lossy(),
&fixture::weights().to_string_lossy(),
)?;

let output_port = model.get_output_by_index(0)?;
assert_eq!(output_port.get_name()?, "MobilenetV2/Predictions/Reshape_1");
assert_eq!(model.get_input_by_index(0)?.get_name()?, "input");

// Retrieve the tensor from the test fixtures.
let data = fs::read(Fixture::tensor())?;
let data = fs::read(fixture::tensor())?;
let input_shape = Shape::new(&[1, 224, 224, 3])?;
let element_type = ElementType::F32;
let mut tensor = Tensor::new(element_type, &input_shape)?;
Expand Down
3 changes: 3 additions & 0 deletions crates/openvino/tests/fixtures/alexnet/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore all downloaded artifacts in this directory (see `../mod.rs`) except this file.
*
!.gitignore
9 changes: 0 additions & 9 deletions crates/openvino/tests/fixtures/alexnet/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions crates/openvino/tests/fixtures/alexnet/alexnet.bin

This file was deleted.

99 changes: 0 additions & 99 deletions crates/openvino/tests/fixtures/alexnet/alexnet.mapping

This file was deleted.

Loading

0 comments on commit 2388a25

Please sign in to comment.