Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
calebrob6 committed Feb 23, 2024
1 parent d36a70d commit 94f3d82
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 31 deletions.
62 changes: 44 additions & 18 deletions docs/tutorials/custom_segmentation_trainer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"flake8: noqa: E501\n",
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
Expand Down Expand Up @@ -52,32 +53,57 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"lines_to_end_of_cell_marker": 2
},
"metadata": {},
"outputs": [],
"source": [
"from torchgeo.trainers import SemanticSegmentationTask\n",
"from torchgeo.datamodules import LandCoverAIDataModule\n",
"# Get rid of the pesky warnings raised by kornia\n",
"# UserWarning: Default grid_sample and affine_grid behavior has changed to align_corners=False since 1.3.0. Please specify align_corners=True if the old behavior is desired. See the documentation of grid_sample for details.\n",
"import warnings"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0b01bf43",
"metadata": {},
"outputs": [],
"source": [
"import lightning\n",
"import lightning.pytorch as pl\n",
"import torch\n",
"from lightning.pytorch.callbacks import ModelCheckpoint\n",
"from torch.optim import AdamW\n",
"from torch.optim.lr_scheduler import CosineAnnealingLR\n",
"from torchmetrics import MetricCollection\n",
"from torchmetrics.classification import (\n",
" Accuracy,\n",
" FBetaScore,\n",
" JaccardIndex,\n",
" Precision,\n",
" Recall,\n",
" JaccardIndex,\n",
")\n",
"\n",
"import lightning.pytorch as pl\n",
"from lightning.pytorch.callbacks import ModelCheckpoint\n",
"import torch\n",
"\n",
"from torch.optim.lr_scheduler import CosineAnnealingLR\n",
"from torch.optim import AdamW\n",
"\n",
"# Get rid of the pesky warnings raised by kornia\n",
"# UserWarning: Default grid_sample and affine_grid behavior has changed to align_corners=False since 1.3.0. Please specify align_corners=True if the old behavior is desired. See the documentation of grid_sample for details.\n",
"import warnings\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3e721f3f",
"metadata": {},
"outputs": [],
"source": [
"from torchgeo.datamodules import LandCoverAIDataModule"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7fb5fbbf",
"metadata": {
"lines_to_end_of_cell_marker": 2
},
"outputs": [],
"source": [
"from torchgeo.trainers import SemanticSegmentationTask\n",
"\n",
"warnings.filterwarnings(\"ignore\", category=UserWarning, module=\"torch.nn.functional\")"
]
Expand Down
28 changes: 15 additions & 13 deletions docs/tutorials/custom_segmentation_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# name: geo
# ---

# flake8: noqa: E501
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# Licensed under the MIT License.
Expand All @@ -35,28 +36,29 @@
#
# Next, we import TorchGeo and any other libraries we need.

# +
from torchgeo.trainers import SemanticSegmentationTask
from torchgeo.datamodules import LandCoverAIDataModule
# Get rid of the pesky warnings raised by kornia
# UserWarning: Default grid_sample and affine_grid behavior has changed to align_corners=False since 1.3.0. Please specify align_corners=True if the old behavior is desired. See the documentation of grid_sample for details.
import warnings

import lightning
import lightning.pytorch as pl
import torch
from lightning.pytorch.callbacks import ModelCheckpoint
from torch.optim import AdamW
from torch.optim.lr_scheduler import CosineAnnealingLR
from torchmetrics import MetricCollection
from torchmetrics.classification import (
Accuracy,
FBetaScore,
JaccardIndex,
Precision,
Recall,
JaccardIndex,
)

import lightning.pytorch as pl
from lightning.pytorch.callbacks import ModelCheckpoint
import torch

from torch.optim.lr_scheduler import CosineAnnealingLR
from torch.optim import AdamW
from torchgeo.datamodules import LandCoverAIDataModule

# Get rid of the pesky warnings raised by kornia
# UserWarning: Default grid_sample and affine_grid behavior has changed to align_corners=False since 1.3.0. Please specify align_corners=True if the old behavior is desired. See the documentation of grid_sample for details.
import warnings
# +
from torchgeo.trainers import SemanticSegmentationTask

warnings.filterwarnings("ignore", category=UserWarning, module="torch.nn.functional")

Expand Down

0 comments on commit 94f3d82

Please sign in to comment.