From 565dd154d6204ee5a0223271e3539c47cc1c844f Mon Sep 17 00:00:00 2001 From: JHZ5583233 <151021300+JHZ5583233@users.noreply.github.com> Date: Tue, 22 Apr 2025 17:20:17 +0200 Subject: [PATCH 01/23] adding base file github actions --- .github/workflows/github-actions.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/github-actions.yml diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml new file mode 100644 index 0000000000..15a61d6b6d --- /dev/null +++ b/.github/workflows/github-actions.yml @@ -0,0 +1,18 @@ +name: GitHub Actions Demo +run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 +on: [push] +jobs: + Explore-GitHub-Actions: + runs-on: ubuntu-latest + steps: + - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" + - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - name: Check out repository code + uses: actions/checkout@v4 + - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." + - run: echo "🖥️ The workflow is now ready to test your code on the runner." + - name: List files in the repository + run: | + ls ${{ github.workspace }} + - run: echo "🍏 This job's status is ${{ job.status }}." From b52bc3a1d457f62a2583b73bf35e875361875b23 Mon Sep 17 00:00:00 2001 From: JHZ5583233 <151021300+JHZ5583233@users.noreply.github.com> Date: Tue, 22 Apr 2025 17:23:02 +0200 Subject: [PATCH 02/23] adding actions --- .github/workflows/github-actions.yml | 34 ++++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 15a61d6b6d..0a102cd096 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -2,17 +2,27 @@ name: GitHub Actions Demo run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 on: [push] jobs: - Explore-GitHub-Actions: + lint: + name: Lint runs-on: ubuntu-latest steps: - - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" - - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - - name: Check out repository code - uses: actions/checkout@v4 - - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." - - name: List files in the repository - run: | - ls ${{ github.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}." + - uses: actions/checkout@v2 + - uses: tonybajan/flake8-check-action@v1.3.0 + mypy: + runs-on: ubuntu-latest + steps: + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: 3.7.4 + architecture: x64 + - name: Checkout + uses: actions/checkout@v3 + - name: Install mypy + run: pip install mypy + - name: Run mypy + uses: sasanquaneuf/mypy-github-action@releases/v1 + with: + checkName: 'mypy' # NOTE: this needs to be the same as the job name + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 992e7a5cbd50d6ac242d31b99b543c3fdcb07174 Mon Sep 17 00:00:00 2001 From: JHZ5583233 <151021300+JHZ5583233@users.noreply.github.com> Date: Tue, 22 Apr 2025 17:25:12 +0200 Subject: [PATCH 03/23] trying to fix flake 8 action --- .github/workflows/github-actions.yml | 51 ++++++++++++++++------------ 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 0a102cd096..48057437ed 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -1,28 +1,35 @@ -name: GitHub Actions Demo -run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 -on: [push] +name: Style check + +on: + push: + branches: + - main + + pull_request: + branches: + - main + jobs: - lint: - name: Lint - runs-on: ubuntu-latest + flake8_py3: + permissions: write-all + runs-on: prroai steps: - - uses: actions/checkout@v2 - - uses: tonybajan/flake8-check-action@v1.3.0 - mypy: - runs-on: ubuntu-latest - steps: - - name: Setup Python - uses: actions/setup-python@v4 + - name: Checkout code + uses: actions/checkout@v2 + + - uses: actions/setup-python@v5 with: - python-version: 3.7.4 - architecture: x64 - - name: Checkout - uses: actions/checkout@v3 - - name: Install mypy - run: pip install mypy - - name: Run mypy - uses: sasanquaneuf/mypy-github-action@releases/v1 + python-version: '3.10' + + - name: Install flake8 + run: pip install flake8 + + - name: Configure Flake8 + run: echo "[flake8]" > .flake8 && echo "extend-ignore = E402" >> .flake8 && echo "exclude = .github" >> .flake8 + + - name: Run flake8 + uses: suo/flake8-github-action@releases/v1 with: - checkName: 'mypy' # NOTE: this needs to be the same as the job name + checkName: "flake8_py3" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 02a7c2d5ceddc574ff5194c1aacb3d37dad0b34a Mon Sep 17 00:00:00 2001 From: JHZ5583233 <151021300+JHZ5583233@users.noreply.github.com> Date: Tue, 22 Apr 2025 17:28:04 +0200 Subject: [PATCH 04/23] Create pylint.yml --- .github/workflows/pylint.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/pylint.yml diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml new file mode 100644 index 0000000000..c73e032c0f --- /dev/null +++ b/.github/workflows/pylint.yml @@ -0,0 +1,23 @@ +name: Pylint + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10"] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pylint + - name: Analysing the code with pylint + run: | + pylint $(git ls-files '*.py') From 91d33dec43fd96672fa81e7db4c73166fd9a7c90 Mon Sep 17 00:00:00 2001 From: JHZ5583233 <151021300+JHZ5583233@users.noreply.github.com> Date: Tue, 22 Apr 2025 17:28:35 +0200 Subject: [PATCH 05/23] Delete .github/workflows/github-actions.yml --- .github/workflows/github-actions.yml | 35 ---------------------------- 1 file changed, 35 deletions(-) delete mode 100644 .github/workflows/github-actions.yml diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml deleted file mode 100644 index 48057437ed..0000000000 --- a/.github/workflows/github-actions.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Style check - -on: - push: - branches: - - main - - pull_request: - branches: - - main - -jobs: - flake8_py3: - permissions: write-all - runs-on: prroai - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - - name: Install flake8 - run: pip install flake8 - - - name: Configure Flake8 - run: echo "[flake8]" > .flake8 && echo "extend-ignore = E402" >> .flake8 && echo "exclude = .github" >> .flake8 - - - name: Run flake8 - uses: suo/flake8-github-action@releases/v1 - with: - checkName: "flake8_py3" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From ee641f24fe495a2fa2fcf4e7a7f2bdde19d9222b Mon Sep 17 00:00:00 2001 From: JHZ5583233 <151021300+JHZ5583233@users.noreply.github.com> Date: Tue, 22 Apr 2025 17:30:28 +0200 Subject: [PATCH 06/23] Create flake.yml --- .github/workflows/flake.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/workflows/flake.yml diff --git a/.github/workflows/flake.yml b/.github/workflows/flake.yml new file mode 100644 index 0000000000..d4e12233a5 --- /dev/null +++ b/.github/workflows/flake.yml @@ -0,0 +1,2 @@ +- name: Flake8 action + uses: suo/flake8-github-action@v1 From 461ae5209544f6344879f1a0c0154f9f0002ca03 Mon Sep 17 00:00:00 2001 From: JHZ5583233 <151021300+JHZ5583233@users.noreply.github.com> Date: Tue, 22 Apr 2025 17:31:25 +0200 Subject: [PATCH 07/23] Update flake.yml --- .github/workflows/flake.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/flake.yml b/.github/workflows/flake.yml index d4e12233a5..5a78f71b20 100644 --- a/.github/workflows/flake.yml +++ b/.github/workflows/flake.yml @@ -1,2 +1,17 @@ -- name: Flake8 action - uses: suo/flake8-github-action@v1 +name: flake8 Lint + +on: [push, pull_request] + +jobs: + flake8-lint: + runs-on: ubuntu-latest + name: Lint + steps: + - name: Check out source repository + uses: actions/checkout@v3 + - name: Set up Python environment + uses: actions/setup-python@v4 + with: + python-version: "3.11" + - name: flake8 Lint + uses: py-actions/flake8@v2 From 32e2606cda54d8997c38d38d90c23f4e5ea878b6 Mon Sep 17 00:00:00 2001 From: JHZ5583233 Date: Wed, 23 Apr 2025 14:48:18 +0200 Subject: [PATCH 08/23] now using given flake 8 yaml file --- .../workflows/flake.yaml | 0 .github/workflows/flake.yml | 17 ----------------- 2 files changed, 17 deletions(-) rename .pre-commit-config.yaml => .github/workflows/flake.yaml (100%) delete mode 100644 .github/workflows/flake.yml diff --git a/.pre-commit-config.yaml b/.github/workflows/flake.yaml similarity index 100% rename from .pre-commit-config.yaml rename to .github/workflows/flake.yaml diff --git a/.github/workflows/flake.yml b/.github/workflows/flake.yml deleted file mode 100644 index 5a78f71b20..0000000000 --- a/.github/workflows/flake.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: flake8 Lint - -on: [push, pull_request] - -jobs: - flake8-lint: - runs-on: ubuntu-latest - name: Lint - steps: - - name: Check out source repository - uses: actions/checkout@v3 - - name: Set up Python environment - uses: actions/setup-python@v4 - with: - python-version: "3.11" - - name: flake8 Lint - uses: py-actions/flake8@v2 From 7ec52b2cd2eba33ef3eeeecd5cd029880129cda9 Mon Sep 17 00:00:00 2001 From: JHZ5583233 Date: Wed, 23 Apr 2025 14:59:31 +0200 Subject: [PATCH 09/23] Revert "now using given flake 8 yaml file" This reverts commit 32e2606cda54d8997c38d38d90c23f4e5ea878b6. --- .github/workflows/flake.yml | 17 +++++++++++++++++ .../flake.yaml => .pre-commit-config.yaml | 0 2 files changed, 17 insertions(+) create mode 100644 .github/workflows/flake.yml rename .github/workflows/flake.yaml => .pre-commit-config.yaml (100%) diff --git a/.github/workflows/flake.yml b/.github/workflows/flake.yml new file mode 100644 index 0000000000..5a78f71b20 --- /dev/null +++ b/.github/workflows/flake.yml @@ -0,0 +1,17 @@ +name: flake8 Lint + +on: [push, pull_request] + +jobs: + flake8-lint: + runs-on: ubuntu-latest + name: Lint + steps: + - name: Check out source repository + uses: actions/checkout@v3 + - name: Set up Python environment + uses: actions/setup-python@v4 + with: + python-version: "3.11" + - name: flake8 Lint + uses: py-actions/flake8@v2 diff --git a/.github/workflows/flake.yaml b/.pre-commit-config.yaml similarity index 100% rename from .github/workflows/flake.yaml rename to .pre-commit-config.yaml From e4c371090d2d5d2f67f52d23ad1cb36bfd1e3962 Mon Sep 17 00:00:00 2001 From: JHZ5583233 <151021300+JHZ5583233@users.noreply.github.com> Date: Wed, 23 Apr 2025 15:05:58 +0200 Subject: [PATCH 10/23] Delete .github/workflows/flake.yml --- .github/workflows/flake.yml | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 .github/workflows/flake.yml diff --git a/.github/workflows/flake.yml b/.github/workflows/flake.yml deleted file mode 100644 index 5a78f71b20..0000000000 --- a/.github/workflows/flake.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: flake8 Lint - -on: [push, pull_request] - -jobs: - flake8-lint: - runs-on: ubuntu-latest - name: Lint - steps: - - name: Check out source repository - uses: actions/checkout@v3 - - name: Set up Python environment - uses: actions/setup-python@v4 - with: - python-version: "3.11" - - name: flake8 Lint - uses: py-actions/flake8@v2 From f85b103cd505a67cb989427cddd40c9f3a2ee0c5 Mon Sep 17 00:00:00 2001 From: JHZ5583233 <151021300+JHZ5583233@users.noreply.github.com> Date: Wed, 23 Apr 2025 15:06:31 +0200 Subject: [PATCH 11/23] added oop flake8 check --- .github/workflows/style.yml | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/style.yml diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml new file mode 100644 index 0000000000..d8e1edd689 --- /dev/null +++ b/.github/workflows/style.yml @@ -0,0 +1,43 @@ +name: Style check + +on: + push: + branches: + - main + - master + + pull_request: + branches: + - main + - master + +jobs: + flake8_py3: + permissions: write-all + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install flake8 and plugins + run: | + pip install flake8 flake8-docstrings flake8-annotations + + - name: Configure Flake8 + run: | + echo "[flake8]" > .flake8 + echo "extend-ignore = E402" >> .flake8 + echo "exclude = .github,autoop/tests" >> .flake8 + # exclude A101, A102, D100 and everything that starts with D2 and D4 + echo "ignore = ANN101,ANN102,D100,D2,D4,ANN002,ANN003" >> .flake8 + + - name: Run flake8 + uses: suo/flake8-github-action@releases/v1 + with: + checkName: "flake8_py3" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From e696c36f49bf51173c73c4e72fb8cab057651598 Mon Sep 17 00:00:00 2001 From: JHZ5583233 Date: Wed, 7 May 2025 13:54:35 +0200 Subject: [PATCH 12/23] removed template code from main --- main.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/main.py b/main.py index e6e9af30ea..e69de29bb2 100644 --- a/main.py +++ b/main.py @@ -1,8 +0,0 @@ -# This is a sample Python script. - -def hello_world(): - return "Hello, World!" - - -if __name__ == '__main__': - hello_world() From b907f410db5eb6044ea0e8302763c220f25e3a76 Mon Sep 17 00:00:00 2001 From: JHZ5583233 Date: Wed, 7 May 2025 13:58:50 +0200 Subject: [PATCH 13/23] removed template unittest --- tests/test_main.py | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 tests/test_main.py diff --git a/tests/test_main.py b/tests/test_main.py deleted file mode 100644 index 1a0f0a6355..0000000000 --- a/tests/test_main.py +++ /dev/null @@ -1,11 +0,0 @@ -import unittest -from main import hello_world - - -class MainTest(unittest.TestCase): - def test_hello(self): - self.assertEqual(hello_world(), "Hello, World!") - - -if __name__ == '__main__': - unittest.main() From 62e6312350713b374d432334a60d7dc70e288724 Mon Sep 17 00:00:00 2001 From: JHZ5583233 Date: Wed, 7 May 2025 14:06:30 +0200 Subject: [PATCH 14/23] updated the workflows --- .../workflows/pre-commit-config.yml | 0 .github/workflows/pylint.yml | 23 ------------------- 2 files changed, 23 deletions(-) rename .pre-commit-config.yaml => .github/workflows/pre-commit-config.yml (100%) delete mode 100644 .github/workflows/pylint.yml diff --git a/.pre-commit-config.yaml b/.github/workflows/pre-commit-config.yml similarity index 100% rename from .pre-commit-config.yaml rename to .github/workflows/pre-commit-config.yml diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml deleted file mode 100644 index c73e032c0f..0000000000 --- a/.github/workflows/pylint.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Pylint - -on: [push] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10"] - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pylint - - name: Analysing the code with pylint - run: | - pylint $(git ls-files '*.py') From 1216c6f6340dee022c9dd51bfe3397eedb717927 Mon Sep 17 00:00:00 2001 From: JHZ5583233 Date: Wed, 7 May 2025 14:08:11 +0200 Subject: [PATCH 15/23] got rid of innit.py for flake 8 compliance --- __init__.py | 0 project_name/__init__.py | 0 project_name/data/__init__.py | 0 project_name/features/__init__.py | 0 project_name/models/__init__.py | 0 tests/__init__.py | 0 tests/data/__init__.py | 0 tests/features/__init__.py | 0 tests/models/__init__.py | 0 9 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 __init__.py delete mode 100644 project_name/__init__.py delete mode 100644 project_name/data/__init__.py delete mode 100644 project_name/features/__init__.py delete mode 100644 project_name/models/__init__.py delete mode 100644 tests/__init__.py delete mode 100644 tests/data/__init__.py delete mode 100644 tests/features/__init__.py delete mode 100644 tests/models/__init__.py diff --git a/__init__.py b/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/project_name/__init__.py b/project_name/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/project_name/data/__init__.py b/project_name/data/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/project_name/features/__init__.py b/project_name/features/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/project_name/models/__init__.py b/project_name/models/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/data/__init__.py b/tests/data/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/features/__init__.py b/tests/features/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/models/__init__.py b/tests/models/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 From eee85f42f951ab4b0efa3e0a4dc8759f29f55966 Mon Sep 17 00:00:00 2001 From: JHZ5583233 Date: Wed, 7 May 2025 14:13:55 +0200 Subject: [PATCH 16/23] changes back for file name --- .../workflows/{pre-commit-config.yml => .pre-commit-config.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{pre-commit-config.yml => .pre-commit-config.yaml} (100%) diff --git a/.github/workflows/pre-commit-config.yml b/.github/workflows/.pre-commit-config.yaml similarity index 100% rename from .github/workflows/pre-commit-config.yml rename to .github/workflows/.pre-commit-config.yaml From 7d8dd1fc109d428d20d4b1e64f8d6453491d564f Mon Sep 17 00:00:00 2001 From: JHZ5583233 Date: Wed, 7 May 2025 14:19:50 +0200 Subject: [PATCH 17/23] changed innit to temp to keep the folders committed --- .../workflows/{.pre-commit-config.yaml => pre-commit-config.yml} | 0 project_name/data/temp.py | 0 project_name/features/temp.py | 0 project_name/models/temp.py | 0 project_name/temp.py | 0 tests/data/temp.py | 0 tests/features/temp.py | 0 tests/models/temp.py | 0 tests/temp.py | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{.pre-commit-config.yaml => pre-commit-config.yml} (100%) create mode 100644 project_name/data/temp.py create mode 100644 project_name/features/temp.py create mode 100644 project_name/models/temp.py create mode 100644 project_name/temp.py create mode 100644 tests/data/temp.py create mode 100644 tests/features/temp.py create mode 100644 tests/models/temp.py create mode 100644 tests/temp.py diff --git a/.github/workflows/.pre-commit-config.yaml b/.github/workflows/pre-commit-config.yml similarity index 100% rename from .github/workflows/.pre-commit-config.yaml rename to .github/workflows/pre-commit-config.yml diff --git a/project_name/data/temp.py b/project_name/data/temp.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/project_name/features/temp.py b/project_name/features/temp.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/project_name/models/temp.py b/project_name/models/temp.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/project_name/temp.py b/project_name/temp.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/temp.py b/tests/data/temp.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/features/temp.py b/tests/features/temp.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/models/temp.py b/tests/models/temp.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/temp.py b/tests/temp.py new file mode 100644 index 0000000000..e69de29bb2 From b7d7debdaca0be8d752fab4b411ba7cd578a4a5d Mon Sep 17 00:00:00 2001 From: juliastgermain <158849790+juliastgermain@users.noreply.github.com> Date: Fri, 16 May 2025 11:44:44 +0200 Subject: [PATCH 18/23] Preprocessing_class created functions for tiling and padding, reconstructing tiles, and then creating rgb depth map from NN output --- project_name/models/Preprocessing_class.py | 140 +++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 project_name/models/Preprocessing_class.py diff --git a/project_name/models/Preprocessing_class.py b/project_name/models/Preprocessing_class.py new file mode 100644 index 0000000000..6b6d8d6b5c --- /dev/null +++ b/project_name/models/Preprocessing_class.py @@ -0,0 +1,140 @@ +import numpy as np +from PIL import Image +import matplotlib.pyplot as plt + + +class Preprocessing: + def __init__(self, tile_size=(256, 256)): + self.tile_size = tile_size + self.last_padding_info = {} + + def is_8_bit(self, np_array): + return np_array.dtype == np.uint8 + + def normalize(self, np_array): + """Normalize array to [0, 1] float32""" + if self.is_8_bit(np_array): + return np_array.astype(np.float32) / 255.0 + if np.issubdtype(np_array.dtype, np.floating): + return np_array.astype(np.float32) + return (np_array / np.iinfo(np_array.dtype).max).astype(np.float32) + + def tile_with_padding(self, np_arrays, pad_mode='constant'): + """Process single or multiple arrays""" + if not isinstance(np_arrays, (list, tuple)): + np_arrays = [np_arrays] + + all_tiles = [] + for idx, np_array in enumerate(np_arrays): + # Validate input before normalization + if not isinstance(np_array, np.ndarray): + raise TypeError("Input must be numpy array") + if not self.is_8_bit(np_array): + raise ValueError("Input must be uint8 array") + + original_shape = np_array.shape + normalized = self.normalize(np_array.copy()) + + tile_h, tile_w = self.tile_size + h, w = original_shape[:2] + + # Calculate padding and store metadata + pad_h = (tile_h - (h % tile_h)) % tile_h + pad_w = (tile_w - (w % tile_w)) % tile_w + + self.last_padding_info[idx] = { + 'original_shape': original_shape, + 'pad_h': pad_h, + 'pad_w': pad_w, + 'is_grayscale': len(original_shape) == 2 + } + + # Create proper pad width + if len(original_shape) == 3: + pad_width = ((0, pad_h), (0, pad_w), (0, 0)) + else: + pad_width = ((0, pad_h), (0, pad_w)) + + padded = np.pad(normalized, pad_width, mode=pad_mode) + padded_h, padded_w = padded.shape[:2] + + # Generate tiles + tiles = [] + for i in range(0, padded_h, tile_h): + for j in range(0, padded_w, tile_w): + tile = padded[i:i + tile_h, j:j + tile_w] + if tile.shape[:2] != (tile_h, tile_w): + tile = np.pad(tile, + ((0, tile_h - tile.shape[0]), + (0, tile_w - tile.shape[1])), + mode=pad_mode) + tiles.append(tile) + all_tiles.extend(tiles) + + return np.array(all_tiles) # Convert to numpy array + + def reconstruct_image(self, tiles, original_idx=0): + """Reconstruct image from tiles""" + info = self.last_padding_info.get(original_idx) + if not info: + raise ValueError("No padding info found for this index") + + tile_h, tile_w = self.tile_size + h, w = info['original_shape'][:2] + pad_h = info['pad_h'] + pad_w = info['pad_w'] + + # Calculate grid dimensions + rows = (h + pad_h) // tile_h + cols = (w + pad_w) // tile_w + + # Create proper reconstruction shape + if info['is_grayscale']: + recon_shape = (h + pad_h, w + pad_w) + else: + recon_shape = (h + pad_h, w + pad_w, info['original_shape'][2]) + + reconstructed = np.zeros(recon_shape, dtype=np.float32) + + # Reconstruct with tiles + for i in range(rows): + for j in range(cols): + idx = i * cols + j + reconstructed[i * tile_h:(i + 1) * tile_h, + j * tile_w:(j + 1) * tile_w] = tiles[idx] + + # Crop and convert + final_image = np.clip(reconstructed[:h,:w], 0, 1) + if info['is_grayscale']: + final_image = np.squeeze(final_image) + + return (final_image * 255).astype(np.uint8) + + def depth_to_rgb(self, depth_map, cmap='plasma'): + """ + Convert a depth map (2D float32 array) to an RGB image using a colormap. + + Args: + depth_map (np.ndarray): 2D array of predicted depth values. + cmap (str): Matplotlib colormap name. + + Returns: + np.ndarray: RGB image (H, W, 3) as uint8. + """ + if not isinstance(depth_map, np.ndarray) or depth_map.ndim != 2: + raise ValueError("Input must be a 2D numpy array (grayscale depth map)") + + # Normalize depth to [0, 1] + min_val = np.min(depth_map) + max_val = np.max(depth_map) + if max_val - min_val == 0: + norm_depth = np.zeros_like(depth_map, dtype=np.float32) + else: + norm_depth = (depth_map - min_val) / (max_val - min_val) + + # Apply colormap + colormap = plt.get_cmap(cmap) + colored = colormap(norm_depth) # Returns RGBA + + rgb = (colored[:, :, :3] * 255).astype(np.uint8) + return rgb \ No newline at end of file From 480bdbbd4e99369063f89e8e03f86db1e5be3677 Mon Sep 17 00:00:00 2001 From: juliastgermain <158849790+juliastgermain@users.noreply.github.com> Date: Fri, 16 May 2025 11:46:12 +0200 Subject: [PATCH 19/23] Preprocessing_class test created with 11 tests looking at normalization, tile padding and reconstruction in both rgb and grayscale, invalid inputs, and depth to rgb --- project_name/models/temp.py | 0 tests/models/unittest_preprocessing.py | 86 ++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) delete mode 100644 project_name/models/temp.py create mode 100644 tests/models/unittest_preprocessing.py diff --git a/project_name/models/temp.py b/project_name/models/temp.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/models/unittest_preprocessing.py b/tests/models/unittest_preprocessing.py new file mode 100644 index 0000000000..ee41e510b1 --- /dev/null +++ b/tests/models/unittest_preprocessing.py @@ -0,0 +1,86 @@ +import unittest +import numpy as np +from project_name.models.Preprocessing_class import Preprocessing + + +class TestPreprocessing(unittest.TestCase): + def setUp(self): + self.tile_size = (256, 256) + self.preprocessor = Preprocessing(tile_size=self.tile_size) + self.rgb_image = np.random.randint(0, 256, (510, 510, 3), dtype=np.uint8) + self.gray_image = np.random.randint(0, 256, (510, 510), dtype=np.uint8) + + def test_is_8_bit(self): + self.assertTrue(self.preprocessor.is_8_bit(self.rgb_image)) + self.assertFalse(self.preprocessor.is_8_bit(self.rgb_image.astype(np.float32))) + + def test_normalize_uint8(self): + norm = self.preprocessor.normalize(self.rgb_image) + self.assertTrue(np.all(norm >= 0.0) and np.all(norm <= 1.0)) + self.assertEqual(norm.dtype, np.float32) + + def test_normalize_float(self): + float_array = self.rgb_image.astype(np.float32) / 255.0 + norm = self.preprocessor.normalize(float_array) + self.assertTrue(np.allclose(float_array, norm)) + self.assertEqual(norm.dtype, np.float32) + + def test_tile_with_padding_rgb(self): + tiles = self.preprocessor.tile_with_padding(self.rgb_image) + expected_num_tiles = ((510 + (256 - 510 % 256)) // 256) ** 2 # 2x2 = 4 + self.assertEqual(tiles.shape[0], expected_num_tiles) + self.assertEqual(tiles.shape[1:], (256, 256, 3)) + + def test_tile_with_padding_grayscale(self): + tiles = self.preprocessor.tile_with_padding(self.gray_image) + expected_num_tiles = ((510 + (256 - 510 % 256)) // 256) ** 2 # 2x2 = 4 + self.assertEqual(tiles.shape[0], expected_num_tiles) + self.assertEqual(tiles.shape[1:], (256, 256)) + + def test_reconstruction_rgb(self): + tiles = self.preprocessor.tile_with_padding(self.rgb_image) + recon = self.preprocessor.reconstruct_image(tiles) + self.assertEqual(recon.shape, self.rgb_image.shape) + self.assertTrue(np.allclose(recon, self.rgb_image, atol=2)) + + def test_reconstruction_grayscale(self): + tiles = self.preprocessor.tile_with_padding(self.gray_image) + recon = self.preprocessor.reconstruct_image(tiles) + self.assertEqual(recon.shape, self.gray_image.shape) + self.assertTrue(np.allclose(recon, self.gray_image, atol=2)) + + def test_invalid_input_type(self): + with self.assertRaises(TypeError): + self.preprocessor.tile_with_padding("not an array") + + def test_invalid_input_dtype(self): + with self.assertRaises(ValueError): + self.preprocessor.tile_with_padding(np.ones((100, 100), dtype=np.float32)) + + def test_missing_padding_info(self): + with self.assertRaises(ValueError): + self.preprocessor.reconstruct_image(np.zeros((4, 256, 256, 3))) + + def test_depth_to_rgb(self): + # Create a mock depth map with float32 values from 0 to 10 + depth_map = np.random.uniform(low=0.0, high=10.0, size=(480, 640)).astype(np.float32) + rgb_depth = self.preprocessor.depth_to_rgb(depth_map, cmap='plasma') + + # Check shape and dtype + self.assertEqual(rgb_depth.shape, (480, 640, 3)) + self.assertEqual(rgb_depth.dtype, np.uint8) + + # Ensure values are within 0–255 + self.assertTrue(np.all(rgb_depth >= 0) and np.all(rgb_depth <= 255)) + + # Check that it's not just black (i.e., has variation) + self.assertGreater(np.std(rgb_depth), 0) + + # Check it raises ValueError for bad input + with self.assertRaises(ValueError): + self.preprocessor.depth_to_rgb(np.ones((10, 10, 3))) # Not 2D + + + +if __name__ == '__main__': + unittest.main() From 390b4ff36a8cbe85a93072774c8faf0576203afb Mon Sep 17 00:00:00 2001 From: juliastgermain <158849790+juliastgermain@users.noreply.github.com> Date: Sat, 17 May 2025 09:48:19 +0200 Subject: [PATCH 20/23] changed some docstrings and comments, deleted what was unneeded --- project_name/models/Preprocessing_class.py | 21 ++++++++++----------- tests/models/unittest_preprocessing.py | 6 ++---- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/project_name/models/Preprocessing_class.py b/project_name/models/Preprocessing_class.py index 6b6d8d6b5c..8888df24a2 100644 --- a/project_name/models/Preprocessing_class.py +++ b/project_name/models/Preprocessing_class.py @@ -20,7 +20,7 @@ def normalize(self, np_array): return (np_array / np.iinfo(np_array.dtype).max).astype(np.float32) def tile_with_padding(self, np_arrays, pad_mode='constant'): - """Process single or multiple arrays""" + """Process single or multiple arrays into tiles with padding""" if not isinstance(np_arrays, (list, tuple)): np_arrays = [np_arrays] @@ -38,7 +38,6 @@ def tile_with_padding(self, np_arrays, pad_mode='constant'): tile_h, tile_w = self.tile_size h, w = original_shape[:2] - # Calculate padding and store metadata pad_h = (tile_h - (h % tile_h)) % tile_h pad_w = (tile_w - (w % tile_w)) % tile_w @@ -49,7 +48,7 @@ def tile_with_padding(self, np_arrays, pad_mode='constant'): 'is_grayscale': len(original_shape) == 2 } - # Create proper pad width + if len(original_shape) == 3: pad_width = ((0, pad_h), (0, pad_w), (0, 0)) else: @@ -58,7 +57,7 @@ def tile_with_padding(self, np_arrays, pad_mode='constant'): padded = np.pad(normalized, pad_width, mode=pad_mode) padded_h, padded_w = padded.shape[:2] - # Generate tiles + tiles = [] for i in range(0, padded_h, tile_h): for j in range(0, padded_w, tile_w): @@ -71,7 +70,7 @@ def tile_with_padding(self, np_arrays, pad_mode='constant'): tiles.append(tile) all_tiles.extend(tiles) - return np.array(all_tiles) # Convert to numpy array + return np.array(all_tiles) def reconstruct_image(self, tiles, original_idx=0): """Reconstruct image from tiles""" @@ -84,11 +83,11 @@ def reconstruct_image(self, tiles, original_idx=0): pad_h = info['pad_h'] pad_w = info['pad_w'] - # Calculate grid dimensions + rows = (h + pad_h) // tile_h cols = (w + pad_w) // tile_w - # Create proper reconstruction shape + if info['is_grayscale']: recon_shape = (h + pad_h, w + pad_w) else: @@ -96,14 +95,14 @@ def reconstruct_image(self, tiles, original_idx=0): reconstructed = np.zeros(recon_shape, dtype=np.float32) - # Reconstruct with tiles + for i in range(rows): for j in range(cols): idx = i * cols + j reconstructed[i * tile_h:(i + 1) * tile_h, j * tile_w:(j + 1) * tile_w] = tiles[idx] - # Crop and convert + final_image = np.clip(reconstructed[:h,:w], 0, 1) if info['is_grayscale']: final_image = np.squeeze(final_image) @@ -124,7 +123,7 @@ def depth_to_rgb(self, depth_map, cmap='plasma'): if not isinstance(depth_map, np.ndarray) or depth_map.ndim != 2: raise ValueError("Input must be a 2D numpy array (grayscale depth map)") - # Normalize depth to [0, 1] + min_val = np.min(depth_map) max_val = np.max(depth_map) if max_val - min_val == 0: @@ -132,7 +131,7 @@ def depth_to_rgb(self, depth_map, cmap='plasma'): else: norm_depth = (depth_map - min_val) / (max_val - min_val) - # Apply colormap + colormap = plt.get_cmap(cmap) colored = colormap(norm_depth) # Returns RGBA diff --git a/tests/models/unittest_preprocessing.py b/tests/models/unittest_preprocessing.py index ee41e510b1..ecf1cc0a76 100644 --- a/tests/models/unittest_preprocessing.py +++ b/tests/models/unittest_preprocessing.py @@ -66,17 +66,15 @@ def test_depth_to_rgb(self): depth_map = np.random.uniform(low=0.0, high=10.0, size=(480, 640)).astype(np.float32) rgb_depth = self.preprocessor.depth_to_rgb(depth_map, cmap='plasma') - # Check shape and dtype + self.assertEqual(rgb_depth.shape, (480, 640, 3)) self.assertEqual(rgb_depth.dtype, np.uint8) - # Ensure values are within 0–255 self.assertTrue(np.all(rgb_depth >= 0) and np.all(rgb_depth <= 255)) - # Check that it's not just black (i.e., has variation) self.assertGreater(np.std(rgb_depth), 0) - # Check it raises ValueError for bad input + with self.assertRaises(ValueError): self.preprocessor.depth_to_rgb(np.ones((10, 10, 3))) # Not 2D From d6c5a1a225e6c1779de7852db9ba507d1fb8f2db Mon Sep 17 00:00:00 2001 From: juliastgermain <158849790+juliastgermain@users.noreply.github.com> Date: Mon, 19 May 2025 14:08:34 +0200 Subject: [PATCH 21/23] delete in blank lines and shortened lines over 79 to adhere to flake8 --- project_name/models/Preprocessing_class.py | 37 +++++++--------- tests/models/unittest_preprocessing.py | 51 +++++++++++++++------- 2 files changed, 51 insertions(+), 37 deletions(-) diff --git a/project_name/models/Preprocessing_class.py b/project_name/models/Preprocessing_class.py index 8888df24a2..ee896a0ce0 100644 --- a/project_name/models/Preprocessing_class.py +++ b/project_name/models/Preprocessing_class.py @@ -1,5 +1,4 @@ import numpy as np -from PIL import Image import matplotlib.pyplot as plt @@ -26,7 +25,6 @@ def tile_with_padding(self, np_arrays, pad_mode='constant'): all_tiles = [] for idx, np_array in enumerate(np_arrays): - # Validate input before normalization if not isinstance(np_array, np.ndarray): raise TypeError("Input must be numpy array") if not self.is_8_bit(np_array): @@ -48,7 +46,6 @@ def tile_with_padding(self, np_arrays, pad_mode='constant'): 'is_grayscale': len(original_shape) == 2 } - if len(original_shape) == 3: pad_width = ((0, pad_h), (0, pad_w), (0, 0)) else: @@ -57,16 +54,17 @@ def tile_with_padding(self, np_arrays, pad_mode='constant'): padded = np.pad(normalized, pad_width, mode=pad_mode) padded_h, padded_w = padded.shape[:2] - tiles = [] for i in range(0, padded_h, tile_h): for j in range(0, padded_w, tile_w): tile = padded[i:i + tile_h, j:j + tile_w] if tile.shape[:2] != (tile_h, tile_w): - tile = np.pad(tile, - ((0, tile_h - tile.shape[0]), - (0, tile_w - tile.shape[1])), - mode=pad_mode) + tile = np.pad( + tile, + ((0, tile_h - tile.shape[0]), + (0, tile_w - tile.shape[1])), + mode=pad_mode + ) tiles.append(tile) all_tiles.extend(tiles) @@ -83,11 +81,9 @@ def reconstruct_image(self, tiles, original_idx=0): pad_h = info['pad_h'] pad_w = info['pad_w'] - rows = (h + pad_h) // tile_h cols = (w + pad_w) // tile_w - if info['is_grayscale']: recon_shape = (h + pad_h, w + pad_w) else: @@ -95,15 +91,15 @@ def reconstruct_image(self, tiles, original_idx=0): reconstructed = np.zeros(recon_shape, dtype=np.float32) - for i in range(rows): for j in range(cols): idx = i * cols + j - reconstructed[i * tile_h:(i + 1) * tile_h, - j * tile_w:(j + 1) * tile_w] = tiles[idx] + reconstructed[ + i * tile_h:(i + 1) * tile_h, + j * tile_w:(j + 1) * tile_w + ] = tiles[idx] - - final_image = np.clip(reconstructed[:h,:w], 0, 1) + final_image = np.clip(reconstructed[:h, :w], 0, 1) if info['is_grayscale']: final_image = np.squeeze(final_image) @@ -111,7 +107,8 @@ def reconstruct_image(self, tiles, original_idx=0): def depth_to_rgb(self, depth_map, cmap='plasma'): """ - Convert a depth map (2D float32 array) to an RGB image using a colormap. + Convert a depth map (2D float32 array) to + an RGB image using a colormap. Args: depth_map (np.ndarray): 2D array of predicted depth values. @@ -121,8 +118,8 @@ def depth_to_rgb(self, depth_map, cmap='plasma'): np.ndarray: RGB image (H, W, 3) as uint8. """ if not isinstance(depth_map, np.ndarray) or depth_map.ndim != 2: - raise ValueError("Input must be a 2D numpy array (grayscale depth map)") - + raise ValueError("Input must be a 2D numpy array " + "(grayscale depth map)") min_val = np.min(depth_map) max_val = np.max(depth_map) @@ -131,9 +128,7 @@ def depth_to_rgb(self, depth_map, cmap='plasma'): else: norm_depth = (depth_map - min_val) / (max_val - min_val) - colormap = plt.get_cmap(cmap) colored = colormap(norm_depth) # Returns RGBA - rgb = (colored[:, :, :3] * 255).astype(np.uint8) - return rgb \ No newline at end of file + return rgb diff --git a/tests/models/unittest_preprocessing.py b/tests/models/unittest_preprocessing.py index ecf1cc0a76..b346403e88 100644 --- a/tests/models/unittest_preprocessing.py +++ b/tests/models/unittest_preprocessing.py @@ -7,12 +7,20 @@ class TestPreprocessing(unittest.TestCase): def setUp(self): self.tile_size = (256, 256) self.preprocessor = Preprocessing(tile_size=self.tile_size) - self.rgb_image = np.random.randint(0, 256, (510, 510, 3), dtype=np.uint8) - self.gray_image = np.random.randint(0, 256, (510, 510), dtype=np.uint8) + self.rgb_image = np.random.randint( + 0, 256, (510, 510, 3), dtype=np.uint8 + ) + self.gray_image = np.random.randint( + 0, 256, (510, 510), dtype=np.uint8 + ) def test_is_8_bit(self): self.assertTrue(self.preprocessor.is_8_bit(self.rgb_image)) - self.assertFalse(self.preprocessor.is_8_bit(self.rgb_image.astype(np.float32))) + self.assertFalse( + self.preprocessor.is_8_bit( + self.rgb_image.astype(np.float32) + ) + ) def test_normalize_uint8(self): norm = self.preprocessor.normalize(self.rgb_image) @@ -27,13 +35,17 @@ def test_normalize_float(self): def test_tile_with_padding_rgb(self): tiles = self.preprocessor.tile_with_padding(self.rgb_image) - expected_num_tiles = ((510 + (256 - 510 % 256)) // 256) ** 2 # 2x2 = 4 + expected_num_tiles = ( + (510 + (256 - 510 % 256)) // 256 + ) ** 2 # 2x2 = 4 self.assertEqual(tiles.shape[0], expected_num_tiles) self.assertEqual(tiles.shape[1:], (256, 256, 3)) def test_tile_with_padding_grayscale(self): tiles = self.preprocessor.tile_with_padding(self.gray_image) - expected_num_tiles = ((510 + (256 - 510 % 256)) // 256) ** 2 # 2x2 = 4 + expected_num_tiles = ( + (510 + (256 - 510 % 256)) // 256 + ) ** 2 # 2x2 = 4 self.assertEqual(tiles.shape[0], expected_num_tiles) self.assertEqual(tiles.shape[1:], (256, 256)) @@ -55,29 +67,36 @@ def test_invalid_input_type(self): def test_invalid_input_dtype(self): with self.assertRaises(ValueError): - self.preprocessor.tile_with_padding(np.ones((100, 100), dtype=np.float32)) + self.preprocessor.tile_with_padding( + np.ones((100, 100), dtype=np.float32) + ) def test_missing_padding_info(self): with self.assertRaises(ValueError): - self.preprocessor.reconstruct_image(np.zeros((4, 256, 256, 3))) + self.preprocessor.reconstruct_image( + np.zeros((4, 256, 256, 3)) + ) def test_depth_to_rgb(self): # Create a mock depth map with float32 values from 0 to 10 - depth_map = np.random.uniform(low=0.0, high=10.0, size=(480, 640)).astype(np.float32) - rgb_depth = self.preprocessor.depth_to_rgb(depth_map, cmap='plasma') - + depth_map = np.random.uniform( + low=0.0, high=10.0, size=(480, 640) + ).astype(np.float32) + rgb_depth = self.preprocessor.depth_to_rgb( + depth_map, cmap='plasma' + ) self.assertEqual(rgb_depth.shape, (480, 640, 3)) self.assertEqual(rgb_depth.dtype, np.uint8) - - self.assertTrue(np.all(rgb_depth >= 0) and np.all(rgb_depth <= 255)) - + self.assertTrue( + np.all(rgb_depth >= 0) and np.all(rgb_depth <= 255) + ) self.assertGreater(np.std(rgb_depth), 0) - with self.assertRaises(ValueError): - self.preprocessor.depth_to_rgb(np.ones((10, 10, 3))) # Not 2D - + self.preprocessor.depth_to_rgb( + np.ones((10, 10, 3)) # Not 2D + ) if __name__ == '__main__': From 25e82e784d0974b324c91c782a76122f0d519ee5 Mon Sep 17 00:00:00 2001 From: juliastgermain <158849790+juliastgermain@users.noreply.github.com> Date: Tue, 20 May 2025 11:51:49 +0200 Subject: [PATCH 22/23] added docstrings for each function the Preprocessing_class.py and type annotations for clarity and formatting --- project_name/models/Preprocessing_class.py | 55 ++++++++++++++-------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/project_name/models/Preprocessing_class.py b/project_name/models/Preprocessing_class.py index ee896a0ce0..81d542222e 100644 --- a/project_name/models/Preprocessing_class.py +++ b/project_name/models/Preprocessing_class.py @@ -1,25 +1,40 @@ import numpy as np import matplotlib.pyplot as plt +from typing import Tuple, Union, List class Preprocessing: - def __init__(self, tile_size=(256, 256)): + def __init__(self, tile_size: Tuple[int, int] = (256, 256)) -> None: + """ + Initialize the Preprocessing class with a tile size. + """ self.tile_size = tile_size - self.last_padding_info = {} + self.last_padding_info: dict[int, dict] = {} - def is_8_bit(self, np_array): + def is_8_bit(self, np_array: np.ndarray) -> bool: + """ + Check if a numpy array is of type uint8. + """ return np_array.dtype == np.uint8 - def normalize(self, np_array): - """Normalize array to [0, 1] float32""" + def normalize(self, np_array: np.ndarray) -> np.ndarray: + """ + Normalize an array to the [0, 1] range as float32. + """ if self.is_8_bit(np_array): return np_array.astype(np.float32) / 255.0 if np.issubdtype(np_array.dtype, np.floating): return np_array.astype(np.float32) return (np_array / np.iinfo(np_array.dtype).max).astype(np.float32) - def tile_with_padding(self, np_arrays, pad_mode='constant'): - """Process single or multiple arrays into tiles with padding""" + def tile_with_padding( + self, + np_arrays: Union[np.ndarray, List[np.ndarray]], + pad_mode: str = 'constant' + ) -> np.ndarray: + """ + Tile one or more images with padding to fit the specified tile size. + """ if not isinstance(np_arrays, (list, tuple)): np_arrays = [np_arrays] @@ -70,8 +85,14 @@ def tile_with_padding(self, np_arrays, pad_mode='constant'): return np.array(all_tiles) - def reconstruct_image(self, tiles, original_idx=0): - """Reconstruct image from tiles""" + def reconstruct_image( + self, + tiles: np.ndarray, + original_idx: int = 0 + ) -> np.ndarray: + """ + Reconstruct the original image from tiles. + """ info = self.last_padding_info.get(original_idx) if not info: raise ValueError("No padding info found for this index") @@ -105,17 +126,13 @@ def reconstruct_image(self, tiles, original_idx=0): return (final_image * 255).astype(np.uint8) - def depth_to_rgb(self, depth_map, cmap='plasma'): + def depth_to_rgb( + self, + depth_map: np.ndarray, + cmap: str = 'plasma' + ) -> np.ndarray: """ - Convert a depth map (2D float32 array) to - an RGB image using a colormap. - - Args: - depth_map (np.ndarray): 2D array of predicted depth values. - cmap (str): Matplotlib colormap name. - - Returns: - np.ndarray: RGB image (H, W, 3) as uint8. + Convert a 2D depth map to a 3-channel RGB image using a colormap. """ if not isinstance(depth_map, np.ndarray) or depth_map.ndim != 2: raise ValueError("Input must be a 2D numpy array " From 7a832cbce42e415bc61966d013b24fbed7bb59b0 Mon Sep 17 00:00:00 2001 From: juliastgermain <158849790+juliastgermain@users.noreply.github.com> Date: Wed, 21 May 2025 15:24:14 +0200 Subject: [PATCH 23/23] deleted temps --- project_name/temp.py | 0 tests/models/temp.py | 0 tests/temp.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 project_name/temp.py delete mode 100644 tests/models/temp.py delete mode 100644 tests/temp.py diff --git a/project_name/temp.py b/project_name/temp.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/models/temp.py b/tests/models/temp.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/temp.py b/tests/temp.py deleted file mode 100644 index e69de29bb2..0000000000