Skip to content

Commit

Permalink
feat: change image class to use PyTorch tensors and methods (#506)
Browse files Browse the repository at this point in the history
Closes #505 

### Summary of Changes

feat: Changed Image class to use PyTorch tensors
refactor: Image class now uses PyTorch transform methods

---------

Co-authored-by: megalinter-bot <[email protected]>
  • Loading branch information
Marsmaennchen221 and megalinter-bot authored Jan 10, 2024
1 parent 28ed5c9 commit efa2b61
Show file tree
Hide file tree
Showing 175 changed files with 1,754 additions and 1,276 deletions.
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

0 comments on commit efa2b61

Please sign in to comment.