This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Imports | |
import pathlib | |
import numpy as np | |
import torch | |
from skimage.io import imread | |
from skimage.transform import resize | |
from inference import predict | |
from transformations import normalize_01, re_normalize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from skimage.io import imread | |
from torch.utils import data | |
class SegmentationDataSet(data.Dataset): | |
def __init__(self, | |
inputs: list, | |
targets: list, | |
transform=None, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from torch import nn | |
import torch | |
@torch.jit.script | |
def autocrop(encoder_layer: torch.Tensor, decoder_layer: torch.Tensor): | |
""" | |
Center-crops the encoder_layer to the size of the decoder_layer, | |
so that merging (concatenation) between levels/blocks is possible. | |
This is only necessary for input sizes != 2**n for 'same' padding and always required for 'valid' padding. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pathlib | |
from utils import get_filenames_of_path | |
root = pathlib.Path(".../Heads") | |
inputs = get_filenames_of_path(root / 'input') | |
inputs.sort() | |
for idx, path in enumerate(inputs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pathlib | |
from typing import List | |
import numpy as np | |
from pytorch_faster_rcnn_tutorial.annotator import Annotator | |
from pytorch_faster_rcnn_tutorial.datasets import ObjectDetectionDatasetSingle | |
from pytorch_faster_rcnn_tutorial.transformations import ( | |
ComposeSingle, | |
FunctionWrapperSingle, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pathlib | |
import torch | |
from utils import get_filenames_of_path | |
root = pathlib.Path("...\Heads") | |
targets = get_filenames_of_path(root / 'target') | |
targets.sort() | |
annotation = torch.load(targets[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import pathlib | |
import sys | |
import warnings | |
from typing import List | |
import numpy as np | |
from pytorch_faster_rcnn_tutorial.datasets import ObjectDetectionDataSet | |
from pytorch_faster_rcnn_tutorial.transformations import ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import pathlib | |
from multiprocessing import Pool | |
from typing import Dict, List | |
import torch | |
from skimage.color import rgba2rgb | |
from skimage.io import imread | |
from torch.utils.data import Dataset | |
from torchvision.ops import box_convert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# visualize dataset | |
color_mapping = { | |
1: 'red', | |
} | |
from visual import DatasetViewer | |
datasetviewer = DatasetViewer(dataset, color_mapping) | |
datasetviewer.napari() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pytorch_faster_rcnn_tutorial.viewers.object_detection_viewer import ObjectDetectionViewer | |
from torchvision.models.detection.transform import GeneralizedRCNNTransform | |
color_mapping: Dict[int, str] = { | |
1: "red", | |
} | |
transform: GeneralizedRCNNTransform = GeneralizedRCNNTransform( | |
min_size=1024, | |
max_size=1024, |