Skip to content
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

make turbojpeg optional #78

Merged
merged 10 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
59 changes: 30 additions & 29 deletions .github/workflows/python_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,34 @@ jobs:
run: sudo apt-get install -y cmake nasm
- name: Build and test
run: make test-python
test-python-macos:
runs-on: macos-latest
steps:
- uses: ilammy/setup-nasm@v1
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
architecture: x64
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: x86_64-apple-darwin
override: true
- uses: messense/maturin-action@v1
with:
command: build
maturin-version: latest
args: --target x86_64-apple-darwin --out dist -m kornia-py/Cargo.toml
- name: Install dependencies
run: |
python -m pip install --upgrade pip |
python -m pip install dist/*.whl |
python -m pip install pytest numpy |
python -m pip install torch --extra-index-url https://download.pytorch.org/whl/cpu
# NOTE: there's a systematic fail with the ci on macos
# test-python-macos:
# runs-on: macos-latest
# steps:
# - uses: ilammy/setup-nasm@v1
# - uses: actions/checkout@v4
# - name: Set up Python 3.8
# uses: actions/setup-python@v5
# with:
# python-version: 3.8
# architecture: x64
# - uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# toolchain: stable
# target: x86_64-apple-darwin
# override: true
# - uses: messense/maturin-action@v1
# with:
# command: build
# maturin-version: latest
# args: --target x86_64-apple-darwin --out dist -m kornia-py/Cargo.toml
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip |
# python -m pip install dist/*.whl |
# python -m pip install pytest numpy |
# python -m pip install torch --extra-index-url https://download.pytorch.org/whl/cpu

- name: Build and test
run: pytest kornia-py/tests
# - name: Build and test
# run: pytest kornia-py/tests
16 changes: 5 additions & 11 deletions .github/workflows/rust_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,15 @@ jobs:
name: Clippy
runs-on: ubuntu-latest
steps:
#- name: Install system dependencies
# run: sudo apt-get install -y cmake nasm libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
override: true
components: clippy
- uses: actions-rs/clippy-check@v1
- uses: giraffate/clippy-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
name: Clippy Output
use-cross: true
reporter: 'github-pr-review'
github_token: ${{ secrets.GITHUB_TOKEN }}
clippy_flags: -- -D warnings

check:
name: Check
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rust_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: test
args: --target ${{ matrix.target }} --features "gstreamer"
args: --target ${{ matrix.target }} --features "gstreamer,jpegturbo"
use-cross: true
build_examples:
name: Build Examples
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ license-file = "LICENSE"
[dependencies]
anyhow = "1.0.80"
fast_image_resize = "3.0.4"
image = { version = "0.25.0" }
ndarray = { version = "0.15.6", features = ["rayon"] }
# optional dependencies
gst = { version = "0.22.2", package = "gstreamer", optional = true }
gst-app = { version = "0.22.0", package = "gstreamer-app", optional = true }
image = { version = "0.25.0" }
memmap2 = "0.9.4"
ndarray = { version = "0.15.6", features = ["rayon"] }
num-traits = "0.2.17"
tokio = { version = "1", features = ["full"], optional = true }
turbojpeg = {version = "1.0.0"}
turbojpeg = { version = "1.0.0", optional = true }
# this is experimental and only used for benchmarking, so it's optional
# consider removing it in the future.
candle-core = { version = "0.3.2", optional = true }
Expand All @@ -36,6 +37,7 @@ walkdir = "2.5.0"
[features]
candle = ["candle-core"]
gstreamer = ["gst", "gst-app", "tokio"]
jpegturbo = ["turbojpeg"]

[[bench]]
name = "bench_color"
Expand Down
2 changes: 1 addition & 1 deletion examples/binarize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use kornia_rs::io::functional as F;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// read the image
let image_path = std::path::Path::new("tests/data/dog.jpeg");
let image: Image<u8, 3> = F::read_image_jpeg(image_path)?;
let image: Image<u8, 3> = F::read_image_any(image_path)?;

// binarize the image as u8
let _image_bin: Image<u8, 3> =
Expand Down
2 changes: 1 addition & 1 deletion examples/color_detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = Args::parse();

// read the image
let rgb = kornia_rs::io::functional::read_image_jpeg(&args.image_path)?;
let rgb = kornia_rs::io::functional::read_image_any(&args.image_path)?;

// binarize the image as u8
let hsv = kornia_rs::color::hsv_from_rgb(&rgb.clone().cast()?)?; // convert to u8 (0-255)
Expand Down
2 changes: 1 addition & 1 deletion examples/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use kornia_rs::io::functional as F;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// read the image
let image_path = std::path::Path::new("tests/data/dog.jpeg");
let image: Image<u8, 3> = F::read_image_jpeg(image_path)?;
let image: Image<u8, 3> = F::read_image_any(image_path)?;

println!("Hello, world!");
println!("Loaded Image size: {:?}", image.size());
Expand Down
2 changes: 1 addition & 1 deletion examples/histogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use kornia_rs::io::functional as F;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// read the image
let image_path = std::path::Path::new("tests/data/dog.jpeg");
let image: Image<u8, 3> = F::read_image_jpeg(image_path)?;
let image: Image<u8, 3> = F::read_image_any(image_path)?;

// create a Rerun recording stream
let rec = rerun::RecordingStreamBuilder::new("Kornia App").spawn()?;
Expand Down
2 changes: 1 addition & 1 deletion examples/imgproc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use kornia_rs::io::functional as F;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// read the image
let image_path = std::path::Path::new("tests/data/dog.jpeg");
let image: Image<u8, 3> = F::read_image_jpeg(image_path)?;
let image: Image<u8, 3> = F::read_image_any(image_path)?;

let image_f32: Image<f32, 3> = image.cast_and_scale::<f32>(1.0 / 255.0)?;

Expand Down
2 changes: 1 addition & 1 deletion examples/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use kornia_rs::io::functional as F;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// read the image
let image_path = std::path::Path::new("tests/data/dog.jpeg");
let image: Image<u8, 3> = F::read_image_jpeg(image_path)?;
let image: Image<u8, 3> = F::read_image_any(image_path)?;

// convert the image to f32 and scale it
let image: Image<f32, 3> = image.cast_and_scale::<f32>(1.0 / 255.0)?;
Expand Down
2 changes: 1 addition & 1 deletion examples/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use kornia_rs::io::functional as F;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// read the image
let image_path = std::path::Path::new("tests/data/dog.jpeg");
let image: Image<u8, 3> = F::read_image_jpeg(image_path)?;
let image: Image<u8, 3> = F::read_image_any(image_path)?;

// cast the image to floating point
let image_f32: Image<f32, 3> = image.clone().cast::<f32>()?;
Expand Down
2 changes: 1 addition & 1 deletion examples/normalize_ii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use kornia_rs::io::functional as F;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// read the image
let image_path = std::path::Path::new("tests/data/dog.jpeg");
let image: Image<u8, 3> = F::read_image_jpeg(image_path)?;
let image: Image<u8, 3> = F::read_image_any(image_path)?;

// cast the image to floating point
let image_f32: Image<f32, 3> = image.clone().cast_and_scale::<f32>(1.0 / 255.0)?;
Expand Down
2 changes: 1 addition & 1 deletion examples/rerun_viz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use kornia_rs::io::functional as F;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// read the image
let image_path = std::path::Path::new("tests/data/dog.jpeg");
let image: Image<u8, 3> = F::read_image_jpeg(image_path)?;
let image: Image<u8, 3> = F::read_image_any(image_path)?;

// create a Rerun recording stream
let rec = rerun::RecordingStreamBuilder::new("Kornia App").spawn()?;
Expand Down
2 changes: 1 addition & 1 deletion examples/rotate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// read the image
let image_path = std::path::Path::new("tests/data/dog.jpeg");

let image: Image<u8, 3> = F::read_image_jpeg(image_path)?;
let image: Image<u8, 3> = F::read_image_any(image_path)?;
let image = image.cast::<f32>()?;

let rec = rerun::RecordingStreamBuilder::new("Kornia App").spawn()?;
Expand Down
2 changes: 1 addition & 1 deletion examples/std_mean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.progress_with(pb)
.for_each(|image_path| {
// read the image
let image = F::read_image_jpeg(&image_path).expect("Failed to read image");
let image = F::read_image_any(&image_path).expect("Failed to read image");

// compute the std and mean
let (std, mean) = kornia_rs::core::std_mean(&image);
Expand Down
Loading
Loading