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

feat: change image class to use PyTorch tensors and methods #506

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2510ddf
refactor: Changed image backend to pytorch tensors
Marsmaennchen221 Nov 23, 2023
0bad2da
test: Changed image tests to skip all cuda tests if cuda not available
Marsmaennchen221 Nov 24, 2023
ed184db
Merge branch 'main' of https://github.com/Safe-DS/Stdlib into image_t…
Marsmaennchen221 Nov 28, 2023
4266ad5
test: All pytorch image tests now use syrupy
Marsmaennchen221 Dec 1, 2023
3bf2ace
test: Added semi transparent image for tests
Marsmaennchen221 Dec 1, 2023
fc0c140
feat: Image default device is now cuda, if cuda is available; else it…
Marsmaennchen221 Dec 8, 2023
4c7e814
Merge branch '505-change-image-class-to-use-pytorch-tensors-pytorch-m…
Marsmaennchen221 Dec 8, 2023
d562452
refactor: updated poetry.lock
Marsmaennchen221 Dec 8, 2023
ced39af
feat: Added Image.from_bytes
Marsmaennchen221 Dec 8, 2023
4b2819c
refactor: Linter comments
Marsmaennchen221 Dec 8, 2023
502c14f
refactor: Linter comments
Marsmaennchen221 Dec 8, 2023
f485139
style: apply automated linter fixes
megalinter-bot Dec 8, 2023
acf330b
style: apply automated linter fixes
megalinter-bot Dec 8, 2023
37757a9
test: Added skip to cuda tests if cuda not available
Marsmaennchen221 Dec 8, 2023
dad2d2c
Merge branch '505-change-image-class-to-use-pytorch-tensors-pytorch-m…
Marsmaennchen221 Dec 8, 2023
4c6bcc1
docs: Updated image_processing.ipynb Tutorial
Marsmaennchen221 Dec 8, 2023
2506d5c
test: Added test for saving images
Marsmaennchen221 Dec 8, 2023
7ad66e4
test: Linter fix
Marsmaennchen221 Dec 8, 2023
13d4bb0
test: Linter fix
Marsmaennchen221 Dec 8, 2023
1bc7ddd
style: apply automated linter fixes
megalinter-bot Dec 8, 2023
95b0bb8
style: apply automated linter fixes
megalinter-bot Dec 8, 2023
2202e71
test: ignore unused snapshots in pytest
Marsmaennchen221 Jan 1, 2024
e251536
Merge branch 'main' of https://github.com/Safe-DS/Stdlib into 505-cha…
Marsmaennchen221 Jan 1, 2024
171a9ba
build: merged poetry
Marsmaennchen221 Jan 1, 2024
c118cc7
test: test every method with every image that could be affacted by th…
Marsmaennchen221 Jan 1, 2024
afd5b86
style: apply automated linter fixes
megalinter-bot Jan 1, 2024
a5833ab
style: apply automated linter fixes
megalinter-bot Jan 1, 2024
7a2b0c7
test: added test for negative contrast
Marsmaennchen221 Jan 1, 2024
f4185ec
Merge branch '505-change-image-class-to-use-pytorch-tensors-pytorch-m…
Marsmaennchen221 Jan 1, 2024
e2234b1
refactor: changed Image.set_device to be private (leading underscore)
Marsmaennchen221 Jan 1, 2024
b30af81
feat: added _get_device in config/_device.py for the default device (…
Marsmaennchen221 Jan 10, 2024
6fc69e2
refactor: readded _default_device in Image to satisfy Ruff linter
Marsmaennchen221 Jan 10, 2024
143d520
docs: Added period for ruff linter
Marsmaennchen221 Jan 10, 2024
d144ae3
style: apply automated linter fixes
megalinter-bot Jan 10, 2024
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
10 changes: 5 additions & 5 deletions docs/tutorials/image_processing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"source": [
"from safeds.data.image.containers import Image\n",
"\n",
"plane = Image.from_png_file(\"data/plane.png\")\n",
"plane = Image.from_file(\"data/plane.png\")\n",
"plane"
]
},
Expand Down Expand Up @@ -175,7 +175,7 @@
"execution_count": null,
"outputs": [],
"source": [
"plane.adjust_color_balance(0.5)"
"# plane.adjust_color_balance(0.5)"
],
"metadata": {
"collapsed": false
Expand Down Expand Up @@ -280,7 +280,7 @@
"execution_count": null,
"outputs": [],
"source": [
"plane.find_edges()\n"
"# plane.find_edges()\n"
],
"metadata": {
"collapsed": false
Expand All @@ -289,7 +289,7 @@
{
"cell_type": "markdown",
"source": [
"13. Add gaussian noise to the `Image`. A higher `standard_deviation` will result in a noisier `Image`:\n"
"13. Add noise to the `Image`. A higher `standard_deviation` will result in a noisier `Image`:\n"
],
"metadata": {
"collapsed": false
Expand All @@ -300,7 +300,7 @@
"execution_count": null,
"outputs": [],
"source": [
"plane.add_gaussian_noise(standard_deviation=0.1)\n"
"plane.add_noise(standard_deviation=0.1)\n"
],
"metadata": {
"collapsed": false
Expand Down
1,579 changes: 896 additions & 683 deletions poetry.lock

Large diffs are not rendered by default.

18 changes: 13 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ packages = [
[tool.poetry.dependencies]
python = "^3.11,<3.12"
ipython = "^8.8.0"
levenshtein = ">=0.21.1,<0.24.0"
matplotlib = "^3.6.3"
openpyxl = "^3.1.2"
pandas = "^2.0.0"
pillow = ">=9.5,<11.0"
scikit-image = ">=0.21,<0.23"
scikit-learn = "^1.2.0"
seaborn = "^0.13.0"
openpyxl = "^3.1.2"
scikit-image = ">=0.21,<0.23"
levenshtein = ">=0.21.1,<0.24.0"
torch = {version = "~2.0.0", source = "torch_cuda118"}
torchvision = {version = "<0.16.0", source = "torch_cuda118"}

[tool.poetry.group.dev.dependencies]
pytest = "^7.2.1"
Expand All @@ -35,19 +37,25 @@ mkdocs = "^1.4.2"
mkdocstrings = ">=0.20,<0.25"
mkdocstrings-python = ">=0.8.3,<1.8.0"
mkdocs-autorefs = ">=0.4.1,<0.6.0"
mkdocs-exclude = "^1.0.2"
mkdocs-gen-files = ">=0.4,<0.6"
mkdocs-glightbox = "^0.3.1"
mkdocs-jupyter = ">=0.23,<0.25"
mkdocs-literate-nav = "^0.6.0"
mkdocs-material = "^9.1.2"
mkdocs-section-index = "^0.3.5"
mkdocs-jupyter = ">=0.23,<0.25"
mkdocs-exclude = "^1.0.2"

[[tool.poetry.source]]
name = "torch_cuda118"
url = "https://download.pytorch.org/whl/cu118"
priority = "explicit"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.pytest.ini_options]
addopts = "--snapshot-warn-unused"
filterwarnings = [
"ignore:Deprecated call to `pkg_resources.declare_namespace",
"ignore:Jupyter is migrating its paths to use standard platformdirs"
Expand Down
7 changes: 7 additions & 0 deletions src/safeds/config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Configuration for Safe-DS."""

from ._device import _get_device

__all__ = [
"_get_device",
]
6 changes: 6 additions & 0 deletions src/safeds/config/_device.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import torch
from torch.types import Device


def _get_device() -> Device:
return torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
Loading