Skip to content

Commit

Permalink
fix python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarriba committed Mar 27, 2024
1 parent 0724ba6 commit 624585b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/python_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@ name: Python Test

on:
pull_request:
paths:
- Cargo.lock
- kornia-py/**
- .github/workflows/test-python.yml
- main
push:
branches:
- main
paths:
- Cargo.lock
- kornia-py/**
- .github/workflows/test-python.yml

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.vscode/
.venv/
**venv/
target/
docker/
docker/
1 change: 1 addition & 0 deletions kornia-py/benchmark/bench_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def read_image_pillow(image_path: str) -> None:
def read_image_kornia(image_path: str) -> None:
return kornia_rs.read_image_jpeg(image_path)


def read_image_tensorflow(image_path: str) -> None:
return tf.keras.utils.load_img(image_path)

Expand Down
6 changes: 3 additions & 3 deletions kornia-py/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ pub type PyImage = Py<PyArray3<u8>>;

/// Trait to convert an image to a PyImage (3D numpy array of u8)
pub trait ToPyImage {
fn to_pyimage(&self) -> PyImage;
fn to_pyimage(self) -> PyImage;
}

impl<const CHANNELS: usize> ToPyImage for kornia_rs::image::Image<u8, CHANNELS> {
fn to_pyimage(&self) -> PyImage {
Python::with_gil(|py| self.data.to_pyarray(py).to_owned())
fn to_pyimage(self) -> PyImage {
Python::with_gil(|py| self.data().to_pyarray(py).to_owned())
}
}

Expand Down

0 comments on commit 624585b

Please sign in to comment.