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

[fix] Fixed Reinhard numpy bug; fixed deprecation issues; updated actions in workflows #60

Merged
merged 13 commits into from
Jan 8, 2025
8 changes: 4 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.x'

Expand All @@ -20,7 +20,7 @@ jobs:
- name: Build wheels
run: python setup.py sdist bdist_wheel

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
path: ./dist/*

Expand All @@ -31,7 +31,7 @@ jobs:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')

steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
Expand Down
38 changes: 16 additions & 22 deletions .github/workflows/tests_full.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: tests
name: Full Tests

on:
push:
Expand All @@ -7,6 +7,7 @@ on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
build:
Expand All @@ -15,9 +16,9 @@ jobs:
if: startsWith(github.ref, 'refs/tags/v') != true

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python 3.6
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.6

Expand All @@ -28,7 +29,7 @@ jobs:
run: python setup.py bdist_wheel

- name: Upload Python wheel
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Python wheel
path: ${{github.workspace}}/dist/torchstain-*.whl
Expand All @@ -39,24 +40,24 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ windows-2019, ubuntu-20.04, macos-12 ]
os: [ windows-2019, ubuntu-20.04, macos-13 ]
python-version: [ 3.7, 3.8, 3.9 ]
tf-version: [2.7.0, 2.8.0, 2.9.0]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Download artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: "Python wheel"

- name: Install dependencies
run: pip install tensorflow==${{ matrix.tf-version }} protobuf==3.20.* opencv-python-headless scikit-image pytest
run: pip install tensorflow==${{ matrix.tf-version }} protobuf==3.20.* opencv-python-headless scikit-image pytest "numpy<2"

- name: Install wheel
run: pip install --find-links=${{github.workspace}} torchstain-*
Expand All @@ -70,31 +71,24 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ windows-2019, ubuntu-20.04, macos-12 ]
python-version: [ 3.6, 3.7, 3.8, 3.9 ]
os: [ windows-2019, ubuntu-20.04, macos-13 ]
python-version: [ 3.7, 3.8, 3.9 ]
pytorch-version: [1.8.0, 1.9.0, 1.10.0, 1.11.0, 1.12.0, 1.13.0]
exclude:
- python-version: 3.6
pytorch-version: 1.11.0
- python-version: 3.6
pytorch-version: 1.12.0
- python-version: 3.6
pytorch-version: 1.13.0

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Download artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: "Python wheel"

- name: Install dependencies
run: pip install torch==${{ matrix.pytorch-version }} torchvision opencv-python-headless scikit-image pytest
run: pip install torch==${{ matrix.pytorch-version }} torchvision opencv-python-headless scikit-image pytest "numpy<2"

- name: Install wheel
run: pip install --find-links=${{github.workspace}} torchstain-*
Expand Down
21 changes: 11 additions & 10 deletions .github/workflows/tests_quick.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: tests
name: Quick Tests

on:
push:
Expand All @@ -7,14 +7,15 @@ on:
pull_request:
branches-ignore:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python 3.6
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.6

Expand All @@ -25,7 +26,7 @@ jobs:
run: python setup.py bdist_wheel

- name: Upload Python wheel
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Python wheel
path: ${{github.workspace}}/dist/torchstain-*.whl
Expand All @@ -36,14 +37,14 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Download artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: "Python wheel"

Expand All @@ -62,14 +63,14 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Download artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: "Python wheel"

Expand Down
6 changes: 2 additions & 4 deletions torchstain/numpy/normalizers/reinhard.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ def fit(self, target):
lab = rgb2lab(target)

# get summary statistics
# stack_ = np.apply_along_axis(get_mean_std, 1, lab_split(lab))
stack_ = np.apply_along_axis(get_mean_std, axis=1, arr=lab_split(lab))
stack_ = np.array([get_mean_std(x) for x in lab_split(lab)])

self.target_means = stack_[:, 0]
self.target_stds = stack_[:, 1]
Expand All @@ -40,8 +39,7 @@ def normalize(self, I):
labs = lab_split(lab)

# get summary statistics from LAB
# stack_ = np.apply_along_axis(get_mean_std, 1, labs)
stack_ = np.apply_along_axis(get_mean_std, axis=1, arr=labs)
stack_ = np.array([get_mean_std(x) for x in labs])

mus = stack_[:, 0]
stds = stack_[:, 1]
Expand Down