SYMBOL INDEX (1635 symbols across 221 files) FILE: lab01/text_recognizer/data/util.py class BaseDataset (line 11) | class BaseDataset(torch.utils.data.Dataset): method __init__ (line 28) | def __init__( method __len__ (line 43) | def __len__(self) -> int: method __getitem__ (line 47) | def __getitem__(self, index: int) -> Tuple[Any, Any]: function convert_strings_to_labels (line 70) | def convert_strings_to_labels(strings: Sequence[str], mapping: Dict[str,... function split_dataset (line 84) | def split_dataset(base_dataset: BaseDataset, fraction: float, seed: int)... function resize_image (line 96) | def resize_image(image: Image.Image, scale_factor: int) -> Image.Image: FILE: lab01/text_recognizer/models/mlp.py class MLP (line 14) | class MLP(nn.Module): method __init__ (line 17) | def __init__( method forward (line 39) | def forward(self, x): method add_to_argparse (line 51) | def add_to_argparse(parser): FILE: lab01/text_recognizer/util.py function to_categorical (line 17) | def to_categorical(y, num_classes): function read_image_pil (line 22) | def read_image_pil(image_uri: Union[Path, str], grayscale=False) -> Image: function read_image_pil_file (line 27) | def read_image_pil_file(image_file, grayscale=False) -> Image: function temporary_working_directory (line 37) | def temporary_working_directory(working_dir: Union[str, Path]): function compute_sha256 (line 47) | def compute_sha256(filename: Union[Path, str]): class TqdmUpTo (line 53) | class TqdmUpTo(tqdm): method update_to (line 56) | def update_to(self, blocks=1, bsize=1, tsize=None): function download_url (line 72) | def download_url(url, filename): FILE: lab02/text_recognizer/data/base_data_module.py function load_and_print_info (line 16) | def load_and_print_info(data_module_class) -> None: function _download_raw_dataset (line 27) | def _download_raw_dataset(metadata: Dict, dl_dirname: Path) -> Path: class BaseDataModule (line 51) | class BaseDataModule(pl.LightningDataModule): method __init__ (line 57) | def __init__(self, args: argparse.Namespace = None) -> None: method data_dirname (line 74) | def data_dirname(cls): method add_to_argparse (line 78) | def add_to_argparse(parser): method config (line 93) | def config(self): method prepare_data (line 97) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 104) | def setup(self, stage: Optional[str] = None) -> None: method train_dataloader (line 111) | def train_dataloader(self): method val_dataloader (line 120) | def val_dataloader(self): method test_dataloader (line 129) | def test_dataloader(self): FILE: lab02/text_recognizer/data/emnist.py class EMNIST (line 32) | class EMNIST(BaseDataModule): method __init__ (line 43) | def __init__(self, args=None): method prepare_data (line 52) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 56) | def setup(self, stage: str = None) -> None: method __repr__ (line 71) | def __repr__(self): function _download_and_process_emnist (line 85) | def _download_and_process_emnist(): function _process_raw_dataset (line 91) | def _process_raw_dataset(filename: str, dirname: Path): function _sample_to_balance (line 133) | def _sample_to_balance(x, y): function _augment_emnist_characters (line 148) | def _augment_emnist_characters(characters: Sequence[str]) -> Sequence[str]: FILE: lab02/text_recognizer/data/emnist_lines.py class EMNISTLines (line 28) | class EMNISTLines(BaseDataModule): method __init__ (line 31) | def __init__( method add_to_argparse (line 55) | def add_to_argparse(parser): method data_filename (line 79) | def data_filename(self): method prepare_data (line 85) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 93) | def setup(self, stage: str = None) -> None: method __repr__ (line 111) | def __repr__(self) -> str: method _generate_data (line 132) | def _generate_data(self, split: str) -> None: function get_samples_by_char (line 168) | def get_samples_by_char(samples, labels, mapping): function select_letter_samples_for_string (line 175) | def select_letter_samples_for_string(string, samples_by_char, char_shape... function construct_image_from_string (line 187) | def construct_image_from_string( function create_dataset_of_images (line 202) | def create_dataset_of_images(N, samples_by_char, sentence_generator, min... function convert_strings_to_labels (line 212) | def convert_strings_to_labels( FILE: lab02/text_recognizer/data/mnist.py class MNIST (line 12) | class MNIST(BaseDataModule): method __init__ (line 15) | def __init__(self, args: argparse.Namespace) -> None: method prepare_data (line 23) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 28) | def setup(self, stage=None) -> None: FILE: lab02/text_recognizer/data/sentence_generator.py class SentenceGenerator (line 15) | class SentenceGenerator: method __init__ (line 18) | def __init__(self, max_length: Optional[int] = None): method generate (line 23) | def generate(self, max_length: Optional[int] = None) -> str: method _get_end_ind_candidates (line 49) | def _get_end_ind_candidates(self, first_ind: int, start_ind: int, max_... function brown_text (line 58) | def brown_text(): function load_nltk_brown_corpus (line 67) | def load_nltk_brown_corpus(): FILE: lab02/text_recognizer/data/util.py class BaseDataset (line 11) | class BaseDataset(torch.utils.data.Dataset): method __init__ (line 28) | def __init__( method __len__ (line 43) | def __len__(self) -> int: method __getitem__ (line 47) | def __getitem__(self, index: int) -> Tuple[Any, Any]: function convert_strings_to_labels (line 70) | def convert_strings_to_labels(strings: Sequence[str], mapping: Dict[str,... function split_dataset (line 84) | def split_dataset(base_dataset: BaseDataset, fraction: float, seed: int)... function resize_image (line 96) | def resize_image(image: Image.Image, scale_factor: int) -> Image.Image: FILE: lab02/text_recognizer/lit_models/base.py class BaseLitModel (line 15) | class BaseLitModel(pl.LightningModule): method __init__ (line 20) | def __init__(self, model, args: argparse.Namespace = None): method add_to_argparse (line 46) | def add_to_argparse(parser): method configure_optimizers (line 54) | def configure_optimizers(self): method forward (line 63) | def forward(self, x): method predict (line 66) | def predict(self, x): method training_step (line 70) | def training_step(self, batch, batch_idx): method _run_on_batch (line 81) | def _run_on_batch(self, batch, with_preds=False): method validation_step (line 88) | def validation_step(self, batch, batch_idx): method test_step (line 99) | def test_step(self, batch, batch_idx): FILE: lab02/text_recognizer/models/cnn.py class ConvBlock (line 15) | class ConvBlock(nn.Module): method __init__ (line 20) | def __init__(self, input_channels: int, output_channels: int) -> None: method forward (line 25) | def forward(self, x: torch.Tensor) -> torch.Tensor: class CNN (line 43) | class CNN(nn.Module): method __init__ (line 46) | def __init__(self, data_config: Dict[str, Any], args: argparse.Namespa... method forward (line 75) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 101) | def add_to_argparse(parser): FILE: lab02/text_recognizer/models/line_cnn_simple.py class LineCNNSimple (line 16) | class LineCNNSimple(nn.Module): method __init__ (line 19) | def __init__( method forward (line 38) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 73) | def add_to_argparse(parser): FILE: lab02/text_recognizer/models/mlp.py class MLP (line 14) | class MLP(nn.Module): method __init__ (line 17) | def __init__( method forward (line 39) | def forward(self, x): method add_to_argparse (line 51) | def add_to_argparse(parser): FILE: lab02/text_recognizer/stems/image.py class ImageStem (line 5) | class ImageStem: method __init__ (line 23) | def __init__(self): method __call__ (line 28) | def __call__(self, img): class MNISTStem (line 38) | class MNISTStem(ImageStem): method __init__ (line 41) | def __init__(self): FILE: lab02/text_recognizer/util.py function to_categorical (line 17) | def to_categorical(y, num_classes): function read_image_pil (line 22) | def read_image_pil(image_uri: Union[Path, str], grayscale=False) -> Image: function read_image_pil_file (line 27) | def read_image_pil_file(image_file, grayscale=False) -> Image: function temporary_working_directory (line 37) | def temporary_working_directory(working_dir: Union[str, Path]): function compute_sha256 (line 47) | def compute_sha256(filename: Union[Path, str]): class TqdmUpTo (line 53) | class TqdmUpTo(tqdm): method update_to (line 56) | def update_to(self, blocks=1, bsize=1, tsize=None): function download_url (line 72) | def download_url(url, filename): FILE: lab02/training/run_experiment.py function _setup_parser (line 19) | def _setup_parser(): function _ensure_logging_dir (line 73) | def _ensure_logging_dir(experiment_dir): function main (line 78) | def main(): FILE: lab02/training/util.py function import_class (line 9) | def import_class(module_and_class_name: str) -> type: function setup_data_and_model_from_args (line 17) | def setup_data_and_model_from_args(args: argparse.Namespace): FILE: lab03/text_recognizer/data/base_data_module.py function load_and_print_info (line 16) | def load_and_print_info(data_module_class) -> None: function _download_raw_dataset (line 27) | def _download_raw_dataset(metadata: Dict, dl_dirname: Path) -> Path: class BaseDataModule (line 51) | class BaseDataModule(pl.LightningDataModule): method __init__ (line 57) | def __init__(self, args: argparse.Namespace = None) -> None: method data_dirname (line 74) | def data_dirname(cls): method add_to_argparse (line 78) | def add_to_argparse(parser): method config (line 93) | def config(self): method prepare_data (line 97) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 104) | def setup(self, stage: Optional[str] = None) -> None: method train_dataloader (line 111) | def train_dataloader(self): method val_dataloader (line 120) | def val_dataloader(self): method test_dataloader (line 129) | def test_dataloader(self): FILE: lab03/text_recognizer/data/emnist.py class EMNIST (line 32) | class EMNIST(BaseDataModule): method __init__ (line 43) | def __init__(self, args=None): method prepare_data (line 52) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 56) | def setup(self, stage: str = None) -> None: method __repr__ (line 71) | def __repr__(self): function _download_and_process_emnist (line 85) | def _download_and_process_emnist(): function _process_raw_dataset (line 91) | def _process_raw_dataset(filename: str, dirname: Path): function _sample_to_balance (line 133) | def _sample_to_balance(x, y): function _augment_emnist_characters (line 148) | def _augment_emnist_characters(characters: Sequence[str]) -> Sequence[str]: FILE: lab03/text_recognizer/data/emnist_lines.py class EMNISTLines (line 28) | class EMNISTLines(BaseDataModule): method __init__ (line 31) | def __init__( method add_to_argparse (line 55) | def add_to_argparse(parser): method data_filename (line 79) | def data_filename(self): method prepare_data (line 85) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 93) | def setup(self, stage: str = None) -> None: method __repr__ (line 111) | def __repr__(self) -> str: method _generate_data (line 132) | def _generate_data(self, split: str) -> None: function get_samples_by_char (line 168) | def get_samples_by_char(samples, labels, mapping): function select_letter_samples_for_string (line 175) | def select_letter_samples_for_string(string, samples_by_char, char_shape... function construct_image_from_string (line 187) | def construct_image_from_string( function create_dataset_of_images (line 202) | def create_dataset_of_images(N, samples_by_char, sentence_generator, min... function convert_strings_to_labels (line 212) | def convert_strings_to_labels( FILE: lab03/text_recognizer/data/iam.py class IAM (line 22) | class IAM: method __init__ (line 40) | def __init__(self): method prepare_data (line 43) | def prepare_data(self): method load_image (line 49) | def load_image(self, id: str) -> Image.Image: method __repr__ (line 62) | def __repr__(self): method all_ids (line 74) | def all_ids(self): method ids_by_split (line 79) | def ids_by_split(self): method split_by_id (line 83) | def split_by_id(self): method train_ids (line 91) | def train_ids(self): method test_ids (line 96) | def test_ids(self): method xml_filenames (line 101) | def xml_filenames(self) -> List[Path]: method validation_ids (line 106) | def validation_ids(self): method form_filenames (line 113) | def form_filenames(self) -> List[Path]: method xml_filenames_by_id (line 118) | def xml_filenames_by_id(self): method form_filenames_by_id (line 123) | def form_filenames_by_id(self): method line_strings_by_id (line 128) | def line_strings_by_id(self): method line_regions_by_id (line 133) | def line_regions_by_id(self): method paragraph_string_by_id (line 138) | def paragraph_string_by_id(self): method paragraph_region_by_id (line 143) | def paragraph_region_by_id(self): function _extract_raw_dataset (line 156) | def _extract_raw_dataset(filename: Path, dirname: Path) -> None: function _get_ids_from_lwitlrt_split_file (line 163) | def _get_ids_from_lwitlrt_split_file(filename: str) -> List[str]: function _get_line_strings_from_xml_file (line 172) | def _get_line_strings_from_xml_file(filename: str) -> List[str]: function _get_text_from_xml_element (line 178) | def _get_text_from_xml_element(xml_element: Any) -> str: function _get_line_regions_from_xml_file (line 183) | def _get_line_regions_from_xml_file(filename: str) -> List[Dict[str, int]]: function _get_line_elements_from_xml_file (line 210) | def _get_line_elements_from_xml_file(filename: str) -> List[Any]: function _get_region_from_xml_element (line 216) | def _get_region_from_xml_element(xml_elem: Any, xml_path: str) -> Option... FILE: lab03/text_recognizer/data/iam_paragraphs.py class IAMParagraphs (line 24) | class IAMParagraphs(BaseDataModule): method __init__ (line 27) | def __init__(self, args: argparse.Namespace = None): method add_to_argparse (line 41) | def add_to_argparse(parser): method prepare_data (line 46) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 75) | def setup(self, stage: str = None) -> None: method __repr__ (line 91) | def __repr__(self) -> str: function validate_input_and_output_dimensions (line 114) | def validate_input_and_output_dimensions( function get_paragraph_crops_and_labels (line 127) | def get_paragraph_crops_and_labels( function save_crops_and_labels (line 143) | def save_crops_and_labels(crops: Dict[str, Image.Image], labels: Dict[st... function load_processed_crops_and_labels (line 154) | def load_processed_crops_and_labels(split: str) -> Tuple[Sequence[Image.... function get_dataset_properties (line 167) | def get_dataset_properties() -> dict: function _labels_filename (line 188) | def _labels_filename(split: str) -> Path: function _crop_filename (line 193) | def _crop_filename(id_: str, split: str) -> Path: function _num_lines (line 198) | def _num_lines(label: str) -> int: FILE: lab03/text_recognizer/data/mnist.py class MNIST (line 12) | class MNIST(BaseDataModule): method __init__ (line 15) | def __init__(self, args: argparse.Namespace) -> None: method prepare_data (line 23) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 28) | def setup(self, stage=None) -> None: FILE: lab03/text_recognizer/data/sentence_generator.py class SentenceGenerator (line 15) | class SentenceGenerator: method __init__ (line 18) | def __init__(self, max_length: Optional[int] = None): method generate (line 23) | def generate(self, max_length: Optional[int] = None) -> str: method _get_end_ind_candidates (line 49) | def _get_end_ind_candidates(self, first_ind: int, start_ind: int, max_... function brown_text (line 58) | def brown_text(): function load_nltk_brown_corpus (line 67) | def load_nltk_brown_corpus(): FILE: lab03/text_recognizer/data/util.py class BaseDataset (line 11) | class BaseDataset(torch.utils.data.Dataset): method __init__ (line 28) | def __init__( method __len__ (line 43) | def __len__(self) -> int: method __getitem__ (line 47) | def __getitem__(self, index: int) -> Tuple[Any, Any]: function convert_strings_to_labels (line 70) | def convert_strings_to_labels(strings: Sequence[str], mapping: Dict[str,... function split_dataset (line 84) | def split_dataset(base_dataset: BaseDataset, fraction: float, seed: int)... function resize_image (line 96) | def resize_image(image: Image.Image, scale_factor: int) -> Image.Image: FILE: lab03/text_recognizer/lit_models/base.py class BaseLitModel (line 17) | class BaseLitModel(pl.LightningModule): method __init__ (line 22) | def __init__(self, model, args: argparse.Namespace = None): method add_to_argparse (line 48) | def add_to_argparse(parser): method configure_optimizers (line 56) | def configure_optimizers(self): method forward (line 65) | def forward(self, x): method predict (line 68) | def predict(self, x): method training_step (line 72) | def training_step(self, batch, batch_idx): method _run_on_batch (line 83) | def _run_on_batch(self, batch, with_preds=False): method validation_step (line 90) | def validation_step(self, batch, batch_idx): method test_step (line 101) | def test_step(self, batch, batch_idx): class BaseImageToTextLitModel (line 109) | class BaseImageToTextLitModel(BaseLitModel): # pylint: disable=too-many... method __init__ (line 112) | def __init__(self, model, args: argparse.Namespace = None): FILE: lab03/text_recognizer/lit_models/metrics.py class CharacterErrorRate (line 8) | class CharacterErrorRate(torchmetrics.CharErrorRate): method __init__ (line 11) | def __init__(self, ignore_tokens: Sequence[int], *args): method update (line 15) | def update(self, preds: torch.Tensor, targets: torch.Tensor): # type:... function test_character_error_rate (line 21) | def test_character_error_rate(): FILE: lab03/text_recognizer/lit_models/transformer.py class TransformerLitModel (line 10) | class TransformerLitModel(BaseImageToTextLitModel): method __init__ (line 18) | def __init__(self, model, args=None): method forward (line 22) | def forward(self, x): method teacher_forward (line 25) | def teacher_forward(self, x: torch.Tensor, y: torch.Tensor) -> torch.T... method training_step (line 44) | def training_step(self, batch, batch_idx): method validation_step (line 55) | def validation_step(self, batch, batch_idx): method test_step (line 72) | def test_step(self, batch, batch_idx): method map (line 89) | def map(self, ks: Sequence[int], ignore: bool = True) -> str: method batchmap (line 96) | def batchmap(self, ks: Sequence[Sequence[int]], ignore=True) -> List[s... method get_preds (line 100) | def get_preds(self, logitlikes: torch.Tensor, replace_after_end: bool ... FILE: lab03/text_recognizer/lit_models/util.py function first_appearance (line 6) | def first_appearance(x: torch.Tensor, element: Union[int, float], dim: i... function replace_after (line 47) | def replace_after(x: torch.Tensor, element: Union[int, float], replace: ... FILE: lab03/text_recognizer/models/cnn.py class ConvBlock (line 15) | class ConvBlock(nn.Module): method __init__ (line 20) | def __init__(self, input_channels: int, output_channels: int) -> None: method forward (line 25) | def forward(self, x: torch.Tensor) -> torch.Tensor: class CNN (line 43) | class CNN(nn.Module): method __init__ (line 46) | def __init__(self, data_config: Dict[str, Any], args: argparse.Namespa... method forward (line 75) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 101) | def add_to_argparse(parser): FILE: lab03/text_recognizer/models/line_cnn_simple.py class LineCNNSimple (line 16) | class LineCNNSimple(nn.Module): method __init__ (line 19) | def __init__( method forward (line 38) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 73) | def add_to_argparse(parser): FILE: lab03/text_recognizer/models/mlp.py class MLP (line 14) | class MLP(nn.Module): method __init__ (line 17) | def __init__( method forward (line 39) | def forward(self, x): method add_to_argparse (line 51) | def add_to_argparse(parser): FILE: lab03/text_recognizer/models/resnet_transformer.py class ResnetTransformer (line 21) | class ResnetTransformer(nn.Module): method __init__ (line 24) | def __init__( method forward (line 75) | def forward(self, x: torch.Tensor) -> torch.Tensor: method init_weights (line 111) | def init_weights(self): method encode (line 123) | def encode(self, x: torch.Tensor) -> torch.Tensor: method decode (line 147) | def decode(self, x, y): method add_to_argparse (line 179) | def add_to_argparse(parser): FILE: lab03/text_recognizer/models/transformer_util.py class PositionalEncodingImage (line 9) | class PositionalEncodingImage(nn.Module): method __init__ (line 16) | def __init__(self, d_model: int, max_h: int = 2000, max_w: int = 2000,... method make_pe (line 26) | def make_pe(d_model: int, max_h: int, max_w: int) -> torch.Tensor: method forward (line 36) | def forward(self, x: Tensor) -> Tensor: class PositionalEncoding (line 44) | class PositionalEncoding(torch.nn.Module): method __init__ (line 47) | def __init__(self, d_model: int, dropout: float = 0.1, max_len: int = ... method make_pe (line 56) | def make_pe(d_model: int, max_len: int) -> torch.Tensor: method forward (line 65) | def forward(self, x: torch.Tensor) -> torch.Tensor: function generate_square_subsequent_mask (line 72) | def generate_square_subsequent_mask(size: int) -> torch.Tensor: FILE: lab03/text_recognizer/stems/image.py class ImageStem (line 5) | class ImageStem: method __init__ (line 23) | def __init__(self): method __call__ (line 28) | def __call__(self, img): class MNISTStem (line 38) | class MNISTStem(ImageStem): method __init__ (line 41) | def __init__(self): FILE: lab03/text_recognizer/stems/paragraph.py class ParagraphStem (line 14) | class ParagraphStem(ImageStem): method __init__ (line 17) | def __init__( FILE: lab03/text_recognizer/util.py function to_categorical (line 17) | def to_categorical(y, num_classes): function read_image_pil (line 22) | def read_image_pil(image_uri: Union[Path, str], grayscale=False) -> Image: function read_image_pil_file (line 27) | def read_image_pil_file(image_file, grayscale=False) -> Image: function temporary_working_directory (line 37) | def temporary_working_directory(working_dir: Union[str, Path]): function compute_sha256 (line 47) | def compute_sha256(filename: Union[Path, str]): class TqdmUpTo (line 53) | class TqdmUpTo(tqdm): method update_to (line 56) | def update_to(self, blocks=1, bsize=1, tsize=None): function download_url (line 72) | def download_url(url, filename): FILE: lab03/training/run_experiment.py function _setup_parser (line 19) | def _setup_parser(): function _ensure_logging_dir (line 73) | def _ensure_logging_dir(experiment_dir): function main (line 78) | def main(): FILE: lab03/training/util.py function import_class (line 9) | def import_class(module_and_class_name: str) -> type: function setup_data_and_model_from_args (line 17) | def setup_data_and_model_from_args(args: argparse.Namespace): FILE: lab04/text_recognizer/callbacks/imtotext.py class ImageToTextTableLogger (line 14) | class ImageToTextTableLogger(pl.Callback): method __init__ (line 17) | def __init__(self, max_images_to_log=32, on_train=True): method on_train_batch_end (line 24) | def on_train_batch_end(self, trainer, module, output, batch, batch_idx): method on_validation_batch_end (line 33) | def on_validation_batch_end(self, trainer, module, output, batch, batc... method _log_image_text_table (line 40) | def _log_image_text_table(self, trainer, output, batch, key): method has_metrics (line 55) | def has_metrics(self, output): class ImageToTextCaptionLogger (line 59) | class ImageToTextCaptionLogger(pl.Callback): method __init__ (line 62) | def __init__(self, max_images_to_log=32, on_train=True): method on_train_batch_end (line 69) | def on_train_batch_end(self, trainer, module, output, batch, batch_idx): method on_validation_batch_end (line 77) | def on_validation_batch_end(self, trainer, module, output, batch, batc... method on_test_batch_end (line 85) | def on_test_batch_end(self, trainer, module, output, batch, batch_idx,... method _log_image_text_caption (line 92) | def _log_image_text_caption(self, trainer, output, batch, key): method has_metrics (line 102) | def has_metrics(self, output): FILE: lab04/text_recognizer/callbacks/model.py class ModelSizeLogger (line 19) | class ModelSizeLogger(pl.Callback): method __init__ (line 22) | def __init__(self, print_size=True): method on_fit_start (line 27) | def on_fit_start(self, trainer, module): method _run (line 30) | def _run(self, trainer, module): method get_model_disksize (line 43) | def get_model_disksize(module): class GraphLogger (line 51) | class GraphLogger(pl.Callback): method __init__ (line 54) | def __init__(self, output_key="logits"): method on_train_batch_end (line 62) | def on_train_batch_end(self, trainer, module, outputs, batch, batch_id... method log_graph (line 72) | def log_graph(trainer, module, outputs): function count_params (line 84) | def count_params(module): FILE: lab04/text_recognizer/callbacks/optim.py class LearningRateMonitor (line 6) | class LearningRateMonitor(pl.callbacks.LearningRateMonitor): method _add_prefix (line 13) | def _add_prefix(self, *args, **kwargs) -> str: FILE: lab04/text_recognizer/callbacks/util.py function check_and_warn (line 6) | def check_and_warn(logger, attribute, feature): function warn_no_attribute (line 12) | def warn_no_attribute(blocked_feature, missing_attribute): FILE: lab04/text_recognizer/data/base_data_module.py function load_and_print_info (line 16) | def load_and_print_info(data_module_class) -> None: function _download_raw_dataset (line 27) | def _download_raw_dataset(metadata: Dict, dl_dirname: Path) -> Path: class BaseDataModule (line 51) | class BaseDataModule(pl.LightningDataModule): method __init__ (line 57) | def __init__(self, args: argparse.Namespace = None) -> None: method data_dirname (line 74) | def data_dirname(cls): method add_to_argparse (line 78) | def add_to_argparse(parser): method config (line 93) | def config(self): method prepare_data (line 97) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 104) | def setup(self, stage: Optional[str] = None) -> None: method train_dataloader (line 111) | def train_dataloader(self): method val_dataloader (line 120) | def val_dataloader(self): method test_dataloader (line 129) | def test_dataloader(self): FILE: lab04/text_recognizer/data/emnist.py class EMNIST (line 32) | class EMNIST(BaseDataModule): method __init__ (line 43) | def __init__(self, args=None): method prepare_data (line 52) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 56) | def setup(self, stage: str = None) -> None: method __repr__ (line 71) | def __repr__(self): function _download_and_process_emnist (line 85) | def _download_and_process_emnist(): function _process_raw_dataset (line 91) | def _process_raw_dataset(filename: str, dirname: Path): function _sample_to_balance (line 133) | def _sample_to_balance(x, y): function _augment_emnist_characters (line 148) | def _augment_emnist_characters(characters: Sequence[str]) -> Sequence[str]: FILE: lab04/text_recognizer/data/emnist_lines.py class EMNISTLines (line 28) | class EMNISTLines(BaseDataModule): method __init__ (line 31) | def __init__( method add_to_argparse (line 55) | def add_to_argparse(parser): method data_filename (line 79) | def data_filename(self): method prepare_data (line 85) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 93) | def setup(self, stage: str = None) -> None: method __repr__ (line 111) | def __repr__(self) -> str: method _generate_data (line 132) | def _generate_data(self, split: str) -> None: function get_samples_by_char (line 168) | def get_samples_by_char(samples, labels, mapping): function select_letter_samples_for_string (line 175) | def select_letter_samples_for_string(string, samples_by_char, char_shape... function construct_image_from_string (line 187) | def construct_image_from_string( function create_dataset_of_images (line 202) | def create_dataset_of_images(N, samples_by_char, sentence_generator, min... function convert_strings_to_labels (line 212) | def convert_strings_to_labels( FILE: lab04/text_recognizer/data/iam.py class IAM (line 22) | class IAM: method __init__ (line 40) | def __init__(self): method prepare_data (line 43) | def prepare_data(self): method load_image (line 49) | def load_image(self, id: str) -> Image.Image: method __repr__ (line 62) | def __repr__(self): method all_ids (line 74) | def all_ids(self): method ids_by_split (line 79) | def ids_by_split(self): method split_by_id (line 83) | def split_by_id(self): method train_ids (line 91) | def train_ids(self): method test_ids (line 96) | def test_ids(self): method xml_filenames (line 101) | def xml_filenames(self) -> List[Path]: method validation_ids (line 106) | def validation_ids(self): method form_filenames (line 113) | def form_filenames(self) -> List[Path]: method xml_filenames_by_id (line 118) | def xml_filenames_by_id(self): method form_filenames_by_id (line 123) | def form_filenames_by_id(self): method line_strings_by_id (line 128) | def line_strings_by_id(self): method line_regions_by_id (line 133) | def line_regions_by_id(self): method paragraph_string_by_id (line 138) | def paragraph_string_by_id(self): method paragraph_region_by_id (line 143) | def paragraph_region_by_id(self): function _extract_raw_dataset (line 156) | def _extract_raw_dataset(filename: Path, dirname: Path) -> None: function _get_ids_from_lwitlrt_split_file (line 163) | def _get_ids_from_lwitlrt_split_file(filename: str) -> List[str]: function _get_line_strings_from_xml_file (line 172) | def _get_line_strings_from_xml_file(filename: str) -> List[str]: function _get_text_from_xml_element (line 178) | def _get_text_from_xml_element(xml_element: Any) -> str: function _get_line_regions_from_xml_file (line 183) | def _get_line_regions_from_xml_file(filename: str) -> List[Dict[str, int]]: function _get_line_elements_from_xml_file (line 210) | def _get_line_elements_from_xml_file(filename: str) -> List[Any]: function _get_region_from_xml_element (line 216) | def _get_region_from_xml_element(xml_elem: Any, xml_path: str) -> Option... FILE: lab04/text_recognizer/data/iam_lines.py class IAMLines (line 24) | class IAMLines(BaseDataModule): method __init__ (line 27) | def __init__(self, args: argparse.Namespace = None): method add_to_argparse (line 38) | def add_to_argparse(parser): method prepare_data (line 43) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 64) | def setup(self, stage: str = None) -> None: method __repr__ (line 91) | def __repr__(self) -> str: function generate_line_crops_and_labels (line 114) | def generate_line_crops_and_labels(iam: IAM, split: str, scale_factor=IM... function save_images_and_labels (line 131) | def save_images_and_labels(crops: Sequence[Image.Image], labels: Sequenc... function load_processed_crops_and_labels (line 140) | def load_processed_crops_and_labels(split: str, data_dirname: Path): function load_processed_line_crops (line 148) | def load_processed_line_crops(split: str, data_dirname: Path): function load_processed_line_labels (line 155) | def load_processed_line_labels(split: str, data_dirname: Path): FILE: lab04/text_recognizer/data/iam_paragraphs.py class IAMParagraphs (line 24) | class IAMParagraphs(BaseDataModule): method __init__ (line 27) | def __init__(self, args: argparse.Namespace = None): method add_to_argparse (line 41) | def add_to_argparse(parser): method prepare_data (line 46) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 75) | def setup(self, stage: str = None) -> None: method __repr__ (line 91) | def __repr__(self) -> str: function validate_input_and_output_dimensions (line 114) | def validate_input_and_output_dimensions( function get_paragraph_crops_and_labels (line 127) | def get_paragraph_crops_and_labels( function save_crops_and_labels (line 143) | def save_crops_and_labels(crops: Dict[str, Image.Image], labels: Dict[st... function load_processed_crops_and_labels (line 154) | def load_processed_crops_and_labels(split: str) -> Tuple[Sequence[Image.... function get_dataset_properties (line 167) | def get_dataset_properties() -> dict: function _labels_filename (line 188) | def _labels_filename(split: str) -> Path: function _crop_filename (line 193) | def _crop_filename(id_: str, split: str) -> Path: function _num_lines (line 198) | def _num_lines(label: str) -> int: FILE: lab04/text_recognizer/data/mnist.py class MNIST (line 12) | class MNIST(BaseDataModule): method __init__ (line 15) | def __init__(self, args: argparse.Namespace) -> None: method prepare_data (line 23) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 28) | def setup(self, stage=None) -> None: FILE: lab04/text_recognizer/data/sentence_generator.py class SentenceGenerator (line 15) | class SentenceGenerator: method __init__ (line 18) | def __init__(self, max_length: Optional[int] = None): method generate (line 23) | def generate(self, max_length: Optional[int] = None) -> str: method _get_end_ind_candidates (line 49) | def _get_end_ind_candidates(self, first_ind: int, start_ind: int, max_... function brown_text (line 58) | def brown_text(): function load_nltk_brown_corpus (line 67) | def load_nltk_brown_corpus(): FILE: lab04/text_recognizer/data/util.py class BaseDataset (line 11) | class BaseDataset(torch.utils.data.Dataset): method __init__ (line 28) | def __init__( method __len__ (line 43) | def __len__(self) -> int: method __getitem__ (line 47) | def __getitem__(self, index: int) -> Tuple[Any, Any]: function convert_strings_to_labels (line 70) | def convert_strings_to_labels(strings: Sequence[str], mapping: Dict[str,... function split_dataset (line 84) | def split_dataset(base_dataset: BaseDataset, fraction: float, seed: int)... function resize_image (line 96) | def resize_image(image: Image.Image, scale_factor: int) -> Image.Image: FILE: lab04/text_recognizer/lit_models/base.py class BaseLitModel (line 17) | class BaseLitModel(pl.LightningModule): method __init__ (line 22) | def __init__(self, model, args: argparse.Namespace = None): method add_to_argparse (line 48) | def add_to_argparse(parser): method configure_optimizers (line 56) | def configure_optimizers(self): method forward (line 65) | def forward(self, x): method predict (line 68) | def predict(self, x): method training_step (line 72) | def training_step(self, batch, batch_idx): method _run_on_batch (line 84) | def _run_on_batch(self, batch, with_preds=False): method validation_step (line 91) | def validation_step(self, batch, batch_idx): method test_step (line 103) | def test_step(self, batch, batch_idx): method add_on_first_batch (line 110) | def add_on_first_batch(self, metrics, outputs, batch_idx): method add_on_logged_batches (line 114) | def add_on_logged_batches(self, metrics, outputs): method is_logged_batch (line 118) | def is_logged_batch(self): class BaseImageToTextLitModel (line 125) | class BaseImageToTextLitModel(BaseLitModel): # pylint: disable=too-many... method __init__ (line 128) | def __init__(self, model, args: argparse.Namespace = None): FILE: lab04/text_recognizer/lit_models/metrics.py class CharacterErrorRate (line 8) | class CharacterErrorRate(torchmetrics.CharErrorRate): method __init__ (line 11) | def __init__(self, ignore_tokens: Sequence[int], *args): method update (line 15) | def update(self, preds: torch.Tensor, targets: torch.Tensor): # type:... function test_character_error_rate (line 21) | def test_character_error_rate(): FILE: lab04/text_recognizer/lit_models/transformer.py class TransformerLitModel (line 10) | class TransformerLitModel(BaseImageToTextLitModel): method __init__ (line 18) | def __init__(self, model, args=None): method forward (line 22) | def forward(self, x): method teacher_forward (line 25) | def teacher_forward(self, x: torch.Tensor, y: torch.Tensor) -> torch.T... method training_step (line 44) | def training_step(self, batch, batch_idx): method validation_step (line 59) | def validation_step(self, batch, batch_idx): method test_step (line 80) | def test_step(self, batch, batch_idx): method map (line 101) | def map(self, ks: Sequence[int], ignore: bool = True) -> str: method batchmap (line 108) | def batchmap(self, ks: Sequence[Sequence[int]], ignore=True) -> List[s... method get_preds (line 112) | def get_preds(self, logitlikes: torch.Tensor, replace_after_end: bool ... FILE: lab04/text_recognizer/lit_models/util.py function first_appearance (line 6) | def first_appearance(x: torch.Tensor, element: Union[int, float], dim: i... function replace_after (line 47) | def replace_after(x: torch.Tensor, element: Union[int, float], replace: ... FILE: lab04/text_recognizer/models/cnn.py class ConvBlock (line 15) | class ConvBlock(nn.Module): method __init__ (line 20) | def __init__(self, input_channels: int, output_channels: int) -> None: method forward (line 25) | def forward(self, x: torch.Tensor) -> torch.Tensor: class CNN (line 43) | class CNN(nn.Module): method __init__ (line 46) | def __init__(self, data_config: Dict[str, Any], args: argparse.Namespa... method forward (line 75) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 101) | def add_to_argparse(parser): FILE: lab04/text_recognizer/models/line_cnn.py class ConvBlock (line 21) | class ConvBlock(nn.Module): method __init__ (line 26) | def __init__( method forward (line 38) | def forward(self, x: torch.Tensor) -> torch.Tensor: class LineCNN (line 56) | class LineCNN(nn.Module): method __init__ (line 61) | def __init__( method _init_weights (line 100) | def _init_weights(self): method forward (line 119) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 146) | def add_to_argparse(parser): FILE: lab04/text_recognizer/models/line_cnn_simple.py class LineCNNSimple (line 16) | class LineCNNSimple(nn.Module): method __init__ (line 19) | def __init__( method forward (line 38) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 73) | def add_to_argparse(parser): FILE: lab04/text_recognizer/models/line_cnn_transformer.py class LineCNNTransformer (line 20) | class LineCNNTransformer(nn.Module): method __init__ (line 23) | def __init__( method init_weights (line 65) | def init_weights(self): method encode (line 71) | def encode(self, x: torch.Tensor) -> torch.Tensor: method decode (line 90) | def decode(self, x, y): method forward (line 117) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 150) | def add_to_argparse(parser): FILE: lab04/text_recognizer/models/mlp.py class MLP (line 14) | class MLP(nn.Module): method __init__ (line 17) | def __init__( method forward (line 39) | def forward(self, x): method add_to_argparse (line 51) | def add_to_argparse(parser): FILE: lab04/text_recognizer/models/resnet_transformer.py class ResnetTransformer (line 21) | class ResnetTransformer(nn.Module): method __init__ (line 24) | def __init__( method forward (line 75) | def forward(self, x: torch.Tensor) -> torch.Tensor: method init_weights (line 111) | def init_weights(self): method encode (line 123) | def encode(self, x: torch.Tensor) -> torch.Tensor: method decode (line 147) | def decode(self, x, y): method add_to_argparse (line 179) | def add_to_argparse(parser): FILE: lab04/text_recognizer/models/transformer_util.py class PositionalEncodingImage (line 9) | class PositionalEncodingImage(nn.Module): method __init__ (line 16) | def __init__(self, d_model: int, max_h: int = 2000, max_w: int = 2000,... method make_pe (line 26) | def make_pe(d_model: int, max_h: int, max_w: int) -> torch.Tensor: method forward (line 36) | def forward(self, x: Tensor) -> Tensor: class PositionalEncoding (line 44) | class PositionalEncoding(torch.nn.Module): method __init__ (line 47) | def __init__(self, d_model: int, dropout: float = 0.1, max_len: int = ... method make_pe (line 56) | def make_pe(d_model: int, max_len: int) -> torch.Tensor: method forward (line 65) | def forward(self, x: torch.Tensor) -> torch.Tensor: function generate_square_subsequent_mask (line 72) | def generate_square_subsequent_mask(size: int) -> torch.Tensor: FILE: lab04/text_recognizer/stems/image.py class ImageStem (line 5) | class ImageStem: method __init__ (line 23) | def __init__(self): method __call__ (line 28) | def __call__(self, img): class MNISTStem (line 38) | class MNISTStem(ImageStem): method __init__ (line 41) | def __init__(self): FILE: lab04/text_recognizer/stems/line.py class LineStem (line 11) | class LineStem(ImageStem): method __init__ (line 14) | def __init__(self, augment=False, color_jitter_kwargs=None, random_aff... class IAMLineStem (line 37) | class IAMLineStem(ImageStem): method __init__ (line 40) | def __init__(self, augment=False, color_jitter_kwargs=None, random_aff... FILE: lab04/text_recognizer/stems/paragraph.py class ParagraphStem (line 14) | class ParagraphStem(ImageStem): method __init__ (line 17) | def __init__( FILE: lab04/text_recognizer/util.py function to_categorical (line 17) | def to_categorical(y, num_classes): function read_image_pil (line 22) | def read_image_pil(image_uri: Union[Path, str], grayscale=False) -> Image: function read_image_pil_file (line 27) | def read_image_pil_file(image_file, grayscale=False) -> Image: function temporary_working_directory (line 37) | def temporary_working_directory(working_dir: Union[str, Path]): function compute_sha256 (line 47) | def compute_sha256(filename: Union[Path, str]): class TqdmUpTo (line 53) | class TqdmUpTo(tqdm): method update_to (line 56) | def update_to(self, blocks=1, bsize=1, tsize=None): function download_url (line 72) | def download_url(url, filename): FILE: lab04/training/run_experiment.py function _setup_parser (line 21) | def _setup_parser(): function _ensure_logging_dir (line 81) | def _ensure_logging_dir(experiment_dir): function main (line 86) | def main(): FILE: lab04/training/util.py function import_class (line 9) | def import_class(module_and_class_name: str) -> type: function setup_data_and_model_from_args (line 17) | def setup_data_and_model_from_args(args: argparse.Namespace): FILE: lab05/text_recognizer/callbacks/imtotext.py class ImageToTextTableLogger (line 14) | class ImageToTextTableLogger(pl.Callback): method __init__ (line 17) | def __init__(self, max_images_to_log=32, on_train=True): method on_train_batch_end (line 24) | def on_train_batch_end(self, trainer, module, output, batch, batch_idx): method on_validation_batch_end (line 33) | def on_validation_batch_end(self, trainer, module, output, batch, batc... method _log_image_text_table (line 40) | def _log_image_text_table(self, trainer, output, batch, key): method has_metrics (line 55) | def has_metrics(self, output): class ImageToTextCaptionLogger (line 59) | class ImageToTextCaptionLogger(pl.Callback): method __init__ (line 62) | def __init__(self, max_images_to_log=32, on_train=True): method on_train_batch_end (line 69) | def on_train_batch_end(self, trainer, module, output, batch, batch_idx): method on_validation_batch_end (line 77) | def on_validation_batch_end(self, trainer, module, output, batch, batc... method on_test_batch_end (line 85) | def on_test_batch_end(self, trainer, module, output, batch, batch_idx,... method _log_image_text_caption (line 92) | def _log_image_text_caption(self, trainer, output, batch, key): method has_metrics (line 102) | def has_metrics(self, output): FILE: lab05/text_recognizer/callbacks/model.py class ModelSizeLogger (line 19) | class ModelSizeLogger(pl.Callback): method __init__ (line 22) | def __init__(self, print_size=True): method on_fit_start (line 27) | def on_fit_start(self, trainer, module): method _run (line 30) | def _run(self, trainer, module): method get_model_disksize (line 43) | def get_model_disksize(module): class GraphLogger (line 51) | class GraphLogger(pl.Callback): method __init__ (line 54) | def __init__(self, output_key="logits"): method on_train_batch_end (line 62) | def on_train_batch_end(self, trainer, module, outputs, batch, batch_id... method log_graph (line 72) | def log_graph(trainer, module, outputs): function count_params (line 84) | def count_params(module): FILE: lab05/text_recognizer/callbacks/optim.py class LearningRateMonitor (line 6) | class LearningRateMonitor(pl.callbacks.LearningRateMonitor): method _add_prefix (line 13) | def _add_prefix(self, *args, **kwargs) -> str: FILE: lab05/text_recognizer/callbacks/util.py function check_and_warn (line 6) | def check_and_warn(logger, attribute, feature): function warn_no_attribute (line 12) | def warn_no_attribute(blocked_feature, missing_attribute): FILE: lab05/text_recognizer/data/base_data_module.py function load_and_print_info (line 16) | def load_and_print_info(data_module_class) -> None: function _download_raw_dataset (line 27) | def _download_raw_dataset(metadata: Dict, dl_dirname: Path) -> Path: class BaseDataModule (line 51) | class BaseDataModule(pl.LightningDataModule): method __init__ (line 57) | def __init__(self, args: argparse.Namespace = None) -> None: method data_dirname (line 74) | def data_dirname(cls): method add_to_argparse (line 78) | def add_to_argparse(parser): method config (line 93) | def config(self): method prepare_data (line 97) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 104) | def setup(self, stage: Optional[str] = None) -> None: method train_dataloader (line 111) | def train_dataloader(self): method val_dataloader (line 120) | def val_dataloader(self): method test_dataloader (line 129) | def test_dataloader(self): FILE: lab05/text_recognizer/data/emnist.py class EMNIST (line 32) | class EMNIST(BaseDataModule): method __init__ (line 43) | def __init__(self, args=None): method prepare_data (line 52) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 56) | def setup(self, stage: str = None) -> None: method __repr__ (line 71) | def __repr__(self): function _download_and_process_emnist (line 85) | def _download_and_process_emnist(): function _process_raw_dataset (line 91) | def _process_raw_dataset(filename: str, dirname: Path): function _sample_to_balance (line 133) | def _sample_to_balance(x, y): function _augment_emnist_characters (line 148) | def _augment_emnist_characters(characters: Sequence[str]) -> Sequence[str]: FILE: lab05/text_recognizer/data/emnist_lines.py class EMNISTLines (line 28) | class EMNISTLines(BaseDataModule): method __init__ (line 31) | def __init__( method add_to_argparse (line 55) | def add_to_argparse(parser): method data_filename (line 79) | def data_filename(self): method prepare_data (line 85) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 93) | def setup(self, stage: str = None) -> None: method __repr__ (line 111) | def __repr__(self) -> str: method _generate_data (line 132) | def _generate_data(self, split: str) -> None: function get_samples_by_char (line 168) | def get_samples_by_char(samples, labels, mapping): function select_letter_samples_for_string (line 175) | def select_letter_samples_for_string(string, samples_by_char, char_shape... function construct_image_from_string (line 187) | def construct_image_from_string( function create_dataset_of_images (line 202) | def create_dataset_of_images(N, samples_by_char, sentence_generator, min... function convert_strings_to_labels (line 212) | def convert_strings_to_labels( FILE: lab05/text_recognizer/data/fake_images.py class FakeImageData (line 15) | class FakeImageData(BaseDataModule): method __init__ (line 18) | def __init__(self, args: argparse.Namespace = None): method add_to_argparse (line 28) | def add_to_argparse(parser): method setup (line 36) | def setup(self, stage: str = None) -> None: FILE: lab05/text_recognizer/data/iam.py class IAM (line 22) | class IAM: method __init__ (line 40) | def __init__(self): method prepare_data (line 43) | def prepare_data(self): method load_image (line 49) | def load_image(self, id: str) -> Image.Image: method __repr__ (line 62) | def __repr__(self): method all_ids (line 74) | def all_ids(self): method ids_by_split (line 79) | def ids_by_split(self): method split_by_id (line 83) | def split_by_id(self): method train_ids (line 91) | def train_ids(self): method test_ids (line 96) | def test_ids(self): method xml_filenames (line 101) | def xml_filenames(self) -> List[Path]: method validation_ids (line 106) | def validation_ids(self): method form_filenames (line 113) | def form_filenames(self) -> List[Path]: method xml_filenames_by_id (line 118) | def xml_filenames_by_id(self): method form_filenames_by_id (line 123) | def form_filenames_by_id(self): method line_strings_by_id (line 128) | def line_strings_by_id(self): method line_regions_by_id (line 133) | def line_regions_by_id(self): method paragraph_string_by_id (line 138) | def paragraph_string_by_id(self): method paragraph_region_by_id (line 143) | def paragraph_region_by_id(self): function _extract_raw_dataset (line 156) | def _extract_raw_dataset(filename: Path, dirname: Path) -> None: function _get_ids_from_lwitlrt_split_file (line 163) | def _get_ids_from_lwitlrt_split_file(filename: str) -> List[str]: function _get_line_strings_from_xml_file (line 172) | def _get_line_strings_from_xml_file(filename: str) -> List[str]: function _get_text_from_xml_element (line 178) | def _get_text_from_xml_element(xml_element: Any) -> str: function _get_line_regions_from_xml_file (line 183) | def _get_line_regions_from_xml_file(filename: str) -> List[Dict[str, int]]: function _get_line_elements_from_xml_file (line 210) | def _get_line_elements_from_xml_file(filename: str) -> List[Any]: function _get_region_from_xml_element (line 216) | def _get_region_from_xml_element(xml_elem: Any, xml_path: str) -> Option... FILE: lab05/text_recognizer/data/iam_lines.py class IAMLines (line 24) | class IAMLines(BaseDataModule): method __init__ (line 27) | def __init__(self, args: argparse.Namespace = None): method add_to_argparse (line 38) | def add_to_argparse(parser): method prepare_data (line 43) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 64) | def setup(self, stage: str = None) -> None: method __repr__ (line 91) | def __repr__(self) -> str: function generate_line_crops_and_labels (line 114) | def generate_line_crops_and_labels(iam: IAM, split: str, scale_factor=IM... function save_images_and_labels (line 131) | def save_images_and_labels(crops: Sequence[Image.Image], labels: Sequenc... function load_processed_crops_and_labels (line 140) | def load_processed_crops_and_labels(split: str, data_dirname: Path): function load_processed_line_crops (line 148) | def load_processed_line_crops(split: str, data_dirname: Path): function load_processed_line_labels (line 155) | def load_processed_line_labels(split: str, data_dirname: Path): FILE: lab05/text_recognizer/data/iam_paragraphs.py class IAMParagraphs (line 24) | class IAMParagraphs(BaseDataModule): method __init__ (line 27) | def __init__(self, args: argparse.Namespace = None): method add_to_argparse (line 41) | def add_to_argparse(parser): method prepare_data (line 46) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 75) | def setup(self, stage: str = None) -> None: method __repr__ (line 91) | def __repr__(self) -> str: function validate_input_and_output_dimensions (line 114) | def validate_input_and_output_dimensions( function get_paragraph_crops_and_labels (line 127) | def get_paragraph_crops_and_labels( function save_crops_and_labels (line 143) | def save_crops_and_labels(crops: Dict[str, Image.Image], labels: Dict[st... function load_processed_crops_and_labels (line 154) | def load_processed_crops_and_labels(split: str) -> Tuple[Sequence[Image.... function get_dataset_properties (line 167) | def get_dataset_properties() -> dict: function _labels_filename (line 188) | def _labels_filename(split: str) -> Path: function _crop_filename (line 193) | def _crop_filename(id_: str, split: str) -> Path: function _num_lines (line 198) | def _num_lines(label: str) -> int: FILE: lab05/text_recognizer/data/mnist.py class MNIST (line 12) | class MNIST(BaseDataModule): method __init__ (line 15) | def __init__(self, args: argparse.Namespace) -> None: method prepare_data (line 23) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 28) | def setup(self, stage=None) -> None: FILE: lab05/text_recognizer/data/sentence_generator.py class SentenceGenerator (line 15) | class SentenceGenerator: method __init__ (line 18) | def __init__(self, max_length: Optional[int] = None): method generate (line 23) | def generate(self, max_length: Optional[int] = None) -> str: method _get_end_ind_candidates (line 49) | def _get_end_ind_candidates(self, first_ind: int, start_ind: int, max_... function brown_text (line 58) | def brown_text(): function load_nltk_brown_corpus (line 67) | def load_nltk_brown_corpus(): FILE: lab05/text_recognizer/data/util.py class BaseDataset (line 11) | class BaseDataset(torch.utils.data.Dataset): method __init__ (line 28) | def __init__( method __len__ (line 43) | def __len__(self) -> int: method __getitem__ (line 47) | def __getitem__(self, index: int) -> Tuple[Any, Any]: function convert_strings_to_labels (line 70) | def convert_strings_to_labels(strings: Sequence[str], mapping: Dict[str,... function split_dataset (line 84) | def split_dataset(base_dataset: BaseDataset, fraction: float, seed: int)... function resize_image (line 96) | def resize_image(image: Image.Image, scale_factor: int) -> Image.Image: FILE: lab05/text_recognizer/lit_models/base.py class BaseLitModel (line 17) | class BaseLitModel(pl.LightningModule): method __init__ (line 22) | def __init__(self, model, args: argparse.Namespace = None): method add_to_argparse (line 48) | def add_to_argparse(parser): method configure_optimizers (line 56) | def configure_optimizers(self): method forward (line 65) | def forward(self, x): method predict (line 68) | def predict(self, x): method training_step (line 72) | def training_step(self, batch, batch_idx): method _run_on_batch (line 84) | def _run_on_batch(self, batch, with_preds=False): method validation_step (line 91) | def validation_step(self, batch, batch_idx): method test_step (line 103) | def test_step(self, batch, batch_idx): method add_on_first_batch (line 110) | def add_on_first_batch(self, metrics, outputs, batch_idx): method add_on_logged_batches (line 114) | def add_on_logged_batches(self, metrics, outputs): method is_logged_batch (line 118) | def is_logged_batch(self): class BaseImageToTextLitModel (line 125) | class BaseImageToTextLitModel(BaseLitModel): # pylint: disable=too-many... method __init__ (line 128) | def __init__(self, model, args: argparse.Namespace = None): FILE: lab05/text_recognizer/lit_models/metrics.py class CharacterErrorRate (line 8) | class CharacterErrorRate(torchmetrics.CharErrorRate): method __init__ (line 11) | def __init__(self, ignore_tokens: Sequence[int], *args): method update (line 15) | def update(self, preds: torch.Tensor, targets: torch.Tensor): # type:... function test_character_error_rate (line 21) | def test_character_error_rate(): FILE: lab05/text_recognizer/lit_models/transformer.py class TransformerLitModel (line 10) | class TransformerLitModel(BaseImageToTextLitModel): method __init__ (line 18) | def __init__(self, model, args=None): method forward (line 22) | def forward(self, x): method teacher_forward (line 25) | def teacher_forward(self, x: torch.Tensor, y: torch.Tensor) -> torch.T... method training_step (line 44) | def training_step(self, batch, batch_idx): method validation_step (line 59) | def validation_step(self, batch, batch_idx): method test_step (line 80) | def test_step(self, batch, batch_idx): method map (line 101) | def map(self, ks: Sequence[int], ignore: bool = True) -> str: method batchmap (line 108) | def batchmap(self, ks: Sequence[Sequence[int]], ignore=True) -> List[s... method get_preds (line 112) | def get_preds(self, logitlikes: torch.Tensor, replace_after_end: bool ... FILE: lab05/text_recognizer/lit_models/util.py function first_appearance (line 6) | def first_appearance(x: torch.Tensor, element: Union[int, float], dim: i... function replace_after (line 47) | def replace_after(x: torch.Tensor, element: Union[int, float], replace: ... FILE: lab05/text_recognizer/models/cnn.py class ConvBlock (line 15) | class ConvBlock(nn.Module): method __init__ (line 20) | def __init__(self, input_channels: int, output_channels: int) -> None: method forward (line 25) | def forward(self, x: torch.Tensor) -> torch.Tensor: class CNN (line 43) | class CNN(nn.Module): method __init__ (line 46) | def __init__(self, data_config: Dict[str, Any], args: argparse.Namespa... method forward (line 75) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 101) | def add_to_argparse(parser): FILE: lab05/text_recognizer/models/line_cnn.py class ConvBlock (line 21) | class ConvBlock(nn.Module): method __init__ (line 26) | def __init__( method forward (line 38) | def forward(self, x: torch.Tensor) -> torch.Tensor: class LineCNN (line 56) | class LineCNN(nn.Module): method __init__ (line 61) | def __init__( method _init_weights (line 100) | def _init_weights(self): method forward (line 119) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 146) | def add_to_argparse(parser): FILE: lab05/text_recognizer/models/line_cnn_simple.py class LineCNNSimple (line 16) | class LineCNNSimple(nn.Module): method __init__ (line 19) | def __init__( method forward (line 38) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 73) | def add_to_argparse(parser): FILE: lab05/text_recognizer/models/line_cnn_transformer.py class LineCNNTransformer (line 20) | class LineCNNTransformer(nn.Module): method __init__ (line 23) | def __init__( method init_weights (line 65) | def init_weights(self): method encode (line 71) | def encode(self, x: torch.Tensor) -> torch.Tensor: method decode (line 90) | def decode(self, x, y): method forward (line 117) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 150) | def add_to_argparse(parser): FILE: lab05/text_recognizer/models/mlp.py class MLP (line 14) | class MLP(nn.Module): method __init__ (line 17) | def __init__( method forward (line 39) | def forward(self, x): method add_to_argparse (line 51) | def add_to_argparse(parser): FILE: lab05/text_recognizer/models/resnet_transformer.py class ResnetTransformer (line 21) | class ResnetTransformer(nn.Module): method __init__ (line 24) | def __init__( method forward (line 75) | def forward(self, x: torch.Tensor) -> torch.Tensor: method init_weights (line 111) | def init_weights(self): method encode (line 123) | def encode(self, x: torch.Tensor) -> torch.Tensor: method decode (line 147) | def decode(self, x, y): method add_to_argparse (line 179) | def add_to_argparse(parser): FILE: lab05/text_recognizer/models/transformer_util.py class PositionalEncodingImage (line 9) | class PositionalEncodingImage(nn.Module): method __init__ (line 16) | def __init__(self, d_model: int, max_h: int = 2000, max_w: int = 2000,... method make_pe (line 26) | def make_pe(d_model: int, max_h: int, max_w: int) -> torch.Tensor: method forward (line 36) | def forward(self, x: Tensor) -> Tensor: class PositionalEncoding (line 44) | class PositionalEncoding(torch.nn.Module): method __init__ (line 47) | def __init__(self, d_model: int, dropout: float = 0.1, max_len: int = ... method make_pe (line 56) | def make_pe(d_model: int, max_len: int) -> torch.Tensor: method forward (line 65) | def forward(self, x: torch.Tensor) -> torch.Tensor: function generate_square_subsequent_mask (line 72) | def generate_square_subsequent_mask(size: int) -> torch.Tensor: FILE: lab05/text_recognizer/stems/image.py class ImageStem (line 5) | class ImageStem: method __init__ (line 23) | def __init__(self): method __call__ (line 28) | def __call__(self, img): class MNISTStem (line 38) | class MNISTStem(ImageStem): method __init__ (line 41) | def __init__(self): FILE: lab05/text_recognizer/stems/line.py class LineStem (line 11) | class LineStem(ImageStem): method __init__ (line 14) | def __init__(self, augment=False, color_jitter_kwargs=None, random_aff... class IAMLineStem (line 37) | class IAMLineStem(ImageStem): method __init__ (line 40) | def __init__(self, augment=False, color_jitter_kwargs=None, random_aff... FILE: lab05/text_recognizer/stems/paragraph.py class ParagraphStem (line 14) | class ParagraphStem(ImageStem): method __init__ (line 17) | def __init__( FILE: lab05/text_recognizer/tests/test_callback_utils.py function test_check_and_warn_simple (line 11) | def test_check_and_warn_simple(): function test_check_and_warn_tblogger (line 23) | def test_check_and_warn_tblogger(): function test_check_and_warn_wandblogger (line 32) | def test_check_and_warn_wandblogger(): FILE: lab05/text_recognizer/tests/test_iam.py function test_iam_parsed_lines (line 5) | def test_iam_parsed_lines(): function test_iam_data_splits (line 13) | def test_iam_data_splits(): FILE: lab05/text_recognizer/util.py function to_categorical (line 17) | def to_categorical(y, num_classes): function read_image_pil (line 22) | def read_image_pil(image_uri: Union[Path, str], grayscale=False) -> Image: function read_image_pil_file (line 27) | def read_image_pil_file(image_file, grayscale=False) -> Image: function temporary_working_directory (line 37) | def temporary_working_directory(working_dir: Union[str, Path]): function compute_sha256 (line 47) | def compute_sha256(filename: Union[Path, str]): class TqdmUpTo (line 53) | class TqdmUpTo(tqdm): method update_to (line 56) | def update_to(self, blocks=1, bsize=1, tsize=None): function download_url (line 72) | def download_url(url, filename): FILE: lab05/training/run_experiment.py function _setup_parser (line 21) | def _setup_parser(): function _ensure_logging_dir (line 87) | def _ensure_logging_dir(experiment_dir): function main (line 92) | def main(): FILE: lab05/training/util.py function import_class (line 9) | def import_class(module_and_class_name: str) -> type: function setup_data_and_model_from_args (line 17) | def setup_data_and_model_from_args(args: argparse.Namespace): FILE: lab06/text_recognizer/callbacks/imtotext.py class ImageToTextTableLogger (line 14) | class ImageToTextTableLogger(pl.Callback): method __init__ (line 17) | def __init__(self, max_images_to_log=32, on_train=True): method on_train_batch_end (line 24) | def on_train_batch_end(self, trainer, module, output, batch, batch_idx): method on_validation_batch_end (line 33) | def on_validation_batch_end(self, trainer, module, output, batch, batc... method _log_image_text_table (line 40) | def _log_image_text_table(self, trainer, output, batch, key): method has_metrics (line 55) | def has_metrics(self, output): class ImageToTextCaptionLogger (line 59) | class ImageToTextCaptionLogger(pl.Callback): method __init__ (line 62) | def __init__(self, max_images_to_log=32, on_train=True): method on_train_batch_end (line 69) | def on_train_batch_end(self, trainer, module, output, batch, batch_idx): method on_validation_batch_end (line 77) | def on_validation_batch_end(self, trainer, module, output, batch, batc... method on_test_batch_end (line 85) | def on_test_batch_end(self, trainer, module, output, batch, batch_idx,... method _log_image_text_caption (line 92) | def _log_image_text_caption(self, trainer, output, batch, key): method has_metrics (line 102) | def has_metrics(self, output): FILE: lab06/text_recognizer/callbacks/model.py class ModelSizeLogger (line 19) | class ModelSizeLogger(pl.Callback): method __init__ (line 22) | def __init__(self, print_size=True): method on_fit_start (line 27) | def on_fit_start(self, trainer, module): method _run (line 30) | def _run(self, trainer, module): method get_model_disksize (line 43) | def get_model_disksize(module): class GraphLogger (line 51) | class GraphLogger(pl.Callback): method __init__ (line 54) | def __init__(self, output_key="logits"): method on_train_batch_end (line 62) | def on_train_batch_end(self, trainer, module, outputs, batch, batch_id... method log_graph (line 72) | def log_graph(trainer, module, outputs): function count_params (line 84) | def count_params(module): FILE: lab06/text_recognizer/callbacks/optim.py class LearningRateMonitor (line 6) | class LearningRateMonitor(pl.callbacks.LearningRateMonitor): method _add_prefix (line 13) | def _add_prefix(self, *args, **kwargs) -> str: FILE: lab06/text_recognizer/callbacks/util.py function check_and_warn (line 6) | def check_and_warn(logger, attribute, feature): function warn_no_attribute (line 12) | def warn_no_attribute(blocked_feature, missing_attribute): FILE: lab06/text_recognizer/data/base_data_module.py function load_and_print_info (line 16) | def load_and_print_info(data_module_class) -> None: function _download_raw_dataset (line 27) | def _download_raw_dataset(metadata: Dict, dl_dirname: Path) -> Path: class BaseDataModule (line 51) | class BaseDataModule(pl.LightningDataModule): method __init__ (line 57) | def __init__(self, args: argparse.Namespace = None) -> None: method data_dirname (line 74) | def data_dirname(cls): method add_to_argparse (line 78) | def add_to_argparse(parser): method config (line 93) | def config(self): method prepare_data (line 97) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 104) | def setup(self, stage: Optional[str] = None) -> None: method train_dataloader (line 111) | def train_dataloader(self): method val_dataloader (line 120) | def val_dataloader(self): method test_dataloader (line 129) | def test_dataloader(self): FILE: lab06/text_recognizer/data/emnist.py class EMNIST (line 32) | class EMNIST(BaseDataModule): method __init__ (line 43) | def __init__(self, args=None): method prepare_data (line 52) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 56) | def setup(self, stage: str = None) -> None: method __repr__ (line 71) | def __repr__(self): function _download_and_process_emnist (line 85) | def _download_and_process_emnist(): function _process_raw_dataset (line 91) | def _process_raw_dataset(filename: str, dirname: Path): function _sample_to_balance (line 133) | def _sample_to_balance(x, y): function _augment_emnist_characters (line 148) | def _augment_emnist_characters(characters: Sequence[str]) -> Sequence[str]: FILE: lab06/text_recognizer/data/emnist_lines.py class EMNISTLines (line 28) | class EMNISTLines(BaseDataModule): method __init__ (line 31) | def __init__( method add_to_argparse (line 55) | def add_to_argparse(parser): method data_filename (line 79) | def data_filename(self): method prepare_data (line 85) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 93) | def setup(self, stage: str = None) -> None: method __repr__ (line 111) | def __repr__(self) -> str: method _generate_data (line 132) | def _generate_data(self, split: str) -> None: function get_samples_by_char (line 168) | def get_samples_by_char(samples, labels, mapping): function select_letter_samples_for_string (line 175) | def select_letter_samples_for_string(string, samples_by_char, char_shape... function construct_image_from_string (line 187) | def construct_image_from_string( function create_dataset_of_images (line 202) | def create_dataset_of_images(N, samples_by_char, sentence_generator, min... function convert_strings_to_labels (line 212) | def convert_strings_to_labels( FILE: lab06/text_recognizer/data/fake_images.py class FakeImageData (line 15) | class FakeImageData(BaseDataModule): method __init__ (line 18) | def __init__(self, args: argparse.Namespace = None): method add_to_argparse (line 28) | def add_to_argparse(parser): method setup (line 36) | def setup(self, stage: str = None) -> None: FILE: lab06/text_recognizer/data/iam.py class IAM (line 22) | class IAM: method __init__ (line 40) | def __init__(self): method prepare_data (line 43) | def prepare_data(self): method load_image (line 49) | def load_image(self, id: str) -> Image.Image: method __repr__ (line 62) | def __repr__(self): method all_ids (line 74) | def all_ids(self): method ids_by_split (line 79) | def ids_by_split(self): method split_by_id (line 83) | def split_by_id(self): method train_ids (line 91) | def train_ids(self): method test_ids (line 96) | def test_ids(self): method xml_filenames (line 101) | def xml_filenames(self) -> List[Path]: method validation_ids (line 106) | def validation_ids(self): method form_filenames (line 113) | def form_filenames(self) -> List[Path]: method xml_filenames_by_id (line 118) | def xml_filenames_by_id(self): method form_filenames_by_id (line 123) | def form_filenames_by_id(self): method line_strings_by_id (line 128) | def line_strings_by_id(self): method line_regions_by_id (line 133) | def line_regions_by_id(self): method paragraph_string_by_id (line 138) | def paragraph_string_by_id(self): method paragraph_region_by_id (line 143) | def paragraph_region_by_id(self): function _extract_raw_dataset (line 156) | def _extract_raw_dataset(filename: Path, dirname: Path) -> None: function _get_ids_from_lwitlrt_split_file (line 163) | def _get_ids_from_lwitlrt_split_file(filename: str) -> List[str]: function _get_line_strings_from_xml_file (line 172) | def _get_line_strings_from_xml_file(filename: str) -> List[str]: function _get_text_from_xml_element (line 178) | def _get_text_from_xml_element(xml_element: Any) -> str: function _get_line_regions_from_xml_file (line 183) | def _get_line_regions_from_xml_file(filename: str) -> List[Dict[str, int]]: function _get_line_elements_from_xml_file (line 210) | def _get_line_elements_from_xml_file(filename: str) -> List[Any]: function _get_region_from_xml_element (line 216) | def _get_region_from_xml_element(xml_elem: Any, xml_path: str) -> Option... FILE: lab06/text_recognizer/data/iam_lines.py class IAMLines (line 24) | class IAMLines(BaseDataModule): method __init__ (line 27) | def __init__(self, args: argparse.Namespace = None): method add_to_argparse (line 38) | def add_to_argparse(parser): method prepare_data (line 43) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 64) | def setup(self, stage: str = None) -> None: method __repr__ (line 91) | def __repr__(self) -> str: function generate_line_crops_and_labels (line 114) | def generate_line_crops_and_labels(iam: IAM, split: str, scale_factor=IM... function save_images_and_labels (line 131) | def save_images_and_labels(crops: Sequence[Image.Image], labels: Sequenc... function load_processed_crops_and_labels (line 140) | def load_processed_crops_and_labels(split: str, data_dirname: Path): function load_processed_line_crops (line 148) | def load_processed_line_crops(split: str, data_dirname: Path): function load_processed_line_labels (line 155) | def load_processed_line_labels(split: str, data_dirname: Path): FILE: lab06/text_recognizer/data/iam_original_and_synthetic_paragraphs.py class IAMOriginalAndSyntheticParagraphs (line 11) | class IAMOriginalAndSyntheticParagraphs(BaseDataModule): method __init__ (line 14) | def __init__(self, args: argparse.Namespace = None): method add_to_argparse (line 26) | def add_to_argparse(parser): method prepare_data (line 32) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 36) | def setup(self, stage: str = None) -> None: method __repr__ (line 47) | def __repr__(self) -> str: FILE: lab06/text_recognizer/data/iam_paragraphs.py class IAMParagraphs (line 24) | class IAMParagraphs(BaseDataModule): method __init__ (line 27) | def __init__(self, args: argparse.Namespace = None): method add_to_argparse (line 41) | def add_to_argparse(parser): method prepare_data (line 46) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 75) | def setup(self, stage: str = None) -> None: method __repr__ (line 91) | def __repr__(self) -> str: function validate_input_and_output_dimensions (line 114) | def validate_input_and_output_dimensions( function get_paragraph_crops_and_labels (line 127) | def get_paragraph_crops_and_labels( function save_crops_and_labels (line 143) | def save_crops_and_labels(crops: Dict[str, Image.Image], labels: Dict[st... function load_processed_crops_and_labels (line 154) | def load_processed_crops_and_labels(split: str) -> Tuple[Sequence[Image.... function get_dataset_properties (line 167) | def get_dataset_properties() -> dict: function _labels_filename (line 188) | def _labels_filename(split: str) -> Path: function _crop_filename (line 193) | def _crop_filename(id_: str, split: str) -> Path: function _num_lines (line 198) | def _num_lines(label: str) -> int: FILE: lab06/text_recognizer/data/iam_synthetic_paragraphs.py class IAMSyntheticParagraphs (line 29) | class IAMSyntheticParagraphs(IAMParagraphs): method __init__ (line 32) | def __init__(self, args: argparse.Namespace = None): method prepare_data (line 39) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 58) | def setup(self, stage: str = None) -> None: method _load_processed_crops_and_labels (line 73) | def _load_processed_crops_and_labels(self): method __repr__ (line 79) | def __repr__(self) -> str: method add_to_argparse (line 98) | def add_to_argparse(parser): class IAMSyntheticParagraphsDataset (line 103) | class IAMSyntheticParagraphsDataset(torch.utils.data.Dataset): method __init__ (line 106) | def __init__( method __len__ (line 131) | def __len__(self) -> int: method _set_seed (line 135) | def _set_seed(self, seed): method __getitem__ (line 141) | def __getitem__(self, index: int) -> Tuple[Any, Any]: function join_line_crops_to_form_paragraph (line 169) | def join_line_crops_to_form_paragraph(line_crops: Sequence[Image.Image])... FILE: lab06/text_recognizer/data/mnist.py class MNIST (line 12) | class MNIST(BaseDataModule): method __init__ (line 15) | def __init__(self, args: argparse.Namespace) -> None: method prepare_data (line 23) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 28) | def setup(self, stage=None) -> None: FILE: lab06/text_recognizer/data/sentence_generator.py class SentenceGenerator (line 15) | class SentenceGenerator: method __init__ (line 18) | def __init__(self, max_length: Optional[int] = None): method generate (line 23) | def generate(self, max_length: Optional[int] = None) -> str: method _get_end_ind_candidates (line 49) | def _get_end_ind_candidates(self, first_ind: int, start_ind: int, max_... function brown_text (line 58) | def brown_text(): function load_nltk_brown_corpus (line 67) | def load_nltk_brown_corpus(): FILE: lab06/text_recognizer/data/util.py class BaseDataset (line 11) | class BaseDataset(torch.utils.data.Dataset): method __init__ (line 28) | def __init__( method __len__ (line 43) | def __len__(self) -> int: method __getitem__ (line 47) | def __getitem__(self, index: int) -> Tuple[Any, Any]: function convert_strings_to_labels (line 70) | def convert_strings_to_labels(strings: Sequence[str], mapping: Dict[str,... function split_dataset (line 84) | def split_dataset(base_dataset: BaseDataset, fraction: float, seed: int)... function resize_image (line 96) | def resize_image(image: Image.Image, scale_factor: int) -> Image.Image: FILE: lab06/text_recognizer/lit_models/base.py class BaseLitModel (line 17) | class BaseLitModel(pl.LightningModule): method __init__ (line 22) | def __init__(self, model, args: argparse.Namespace = None): method add_to_argparse (line 48) | def add_to_argparse(parser): method configure_optimizers (line 56) | def configure_optimizers(self): method forward (line 65) | def forward(self, x): method predict (line 68) | def predict(self, x): method training_step (line 72) | def training_step(self, batch, batch_idx): method _run_on_batch (line 84) | def _run_on_batch(self, batch, with_preds=False): method validation_step (line 91) | def validation_step(self, batch, batch_idx): method test_step (line 103) | def test_step(self, batch, batch_idx): method add_on_first_batch (line 110) | def add_on_first_batch(self, metrics, outputs, batch_idx): method add_on_logged_batches (line 114) | def add_on_logged_batches(self, metrics, outputs): method is_logged_batch (line 118) | def is_logged_batch(self): class BaseImageToTextLitModel (line 125) | class BaseImageToTextLitModel(BaseLitModel): # pylint: disable=too-many... method __init__ (line 128) | def __init__(self, model, args: argparse.Namespace = None): FILE: lab06/text_recognizer/lit_models/metrics.py class CharacterErrorRate (line 8) | class CharacterErrorRate(torchmetrics.CharErrorRate): method __init__ (line 11) | def __init__(self, ignore_tokens: Sequence[int], *args): method update (line 15) | def update(self, preds: torch.Tensor, targets: torch.Tensor): # type:... function test_character_error_rate (line 21) | def test_character_error_rate(): FILE: lab06/text_recognizer/lit_models/transformer.py class TransformerLitModel (line 10) | class TransformerLitModel(BaseImageToTextLitModel): method __init__ (line 18) | def __init__(self, model, args=None): method forward (line 22) | def forward(self, x): method teacher_forward (line 25) | def teacher_forward(self, x: torch.Tensor, y: torch.Tensor) -> torch.T... method training_step (line 44) | def training_step(self, batch, batch_idx): method validation_step (line 59) | def validation_step(self, batch, batch_idx): method test_step (line 80) | def test_step(self, batch, batch_idx): method map (line 101) | def map(self, ks: Sequence[int], ignore: bool = True) -> str: method batchmap (line 108) | def batchmap(self, ks: Sequence[Sequence[int]], ignore=True) -> List[s... method get_preds (line 112) | def get_preds(self, logitlikes: torch.Tensor, replace_after_end: bool ... FILE: lab06/text_recognizer/lit_models/util.py function first_appearance (line 6) | def first_appearance(x: torch.Tensor, element: Union[int, float], dim: i... function replace_after (line 47) | def replace_after(x: torch.Tensor, element: Union[int, float], replace: ... FILE: lab06/text_recognizer/models/cnn.py class ConvBlock (line 15) | class ConvBlock(nn.Module): method __init__ (line 20) | def __init__(self, input_channels: int, output_channels: int) -> None: method forward (line 25) | def forward(self, x: torch.Tensor) -> torch.Tensor: class CNN (line 43) | class CNN(nn.Module): method __init__ (line 46) | def __init__(self, data_config: Dict[str, Any], args: argparse.Namespa... method forward (line 75) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 101) | def add_to_argparse(parser): FILE: lab06/text_recognizer/models/line_cnn.py class ConvBlock (line 21) | class ConvBlock(nn.Module): method __init__ (line 26) | def __init__( method forward (line 38) | def forward(self, x: torch.Tensor) -> torch.Tensor: class LineCNN (line 56) | class LineCNN(nn.Module): method __init__ (line 61) | def __init__( method _init_weights (line 100) | def _init_weights(self): method forward (line 119) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 146) | def add_to_argparse(parser): FILE: lab06/text_recognizer/models/line_cnn_simple.py class LineCNNSimple (line 16) | class LineCNNSimple(nn.Module): method __init__ (line 19) | def __init__( method forward (line 38) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 73) | def add_to_argparse(parser): FILE: lab06/text_recognizer/models/line_cnn_transformer.py class LineCNNTransformer (line 20) | class LineCNNTransformer(nn.Module): method __init__ (line 23) | def __init__( method init_weights (line 65) | def init_weights(self): method encode (line 71) | def encode(self, x: torch.Tensor) -> torch.Tensor: method decode (line 90) | def decode(self, x, y): method forward (line 117) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 150) | def add_to_argparse(parser): FILE: lab06/text_recognizer/models/mlp.py class MLP (line 14) | class MLP(nn.Module): method __init__ (line 17) | def __init__( method forward (line 39) | def forward(self, x): method add_to_argparse (line 51) | def add_to_argparse(parser): FILE: lab06/text_recognizer/models/resnet_transformer.py class ResnetTransformer (line 21) | class ResnetTransformer(nn.Module): method __init__ (line 24) | def __init__( method forward (line 75) | def forward(self, x: torch.Tensor) -> torch.Tensor: method init_weights (line 111) | def init_weights(self): method encode (line 123) | def encode(self, x: torch.Tensor) -> torch.Tensor: method decode (line 147) | def decode(self, x, y): method add_to_argparse (line 179) | def add_to_argparse(parser): FILE: lab06/text_recognizer/models/transformer_util.py class PositionalEncodingImage (line 9) | class PositionalEncodingImage(nn.Module): method __init__ (line 16) | def __init__(self, d_model: int, max_h: int = 2000, max_w: int = 2000,... method make_pe (line 26) | def make_pe(d_model: int, max_h: int, max_w: int) -> torch.Tensor: method forward (line 36) | def forward(self, x: Tensor) -> Tensor: class PositionalEncoding (line 44) | class PositionalEncoding(torch.nn.Module): method __init__ (line 47) | def __init__(self, d_model: int, dropout: float = 0.1, max_len: int = ... method make_pe (line 56) | def make_pe(d_model: int, max_len: int) -> torch.Tensor: method forward (line 65) | def forward(self, x: torch.Tensor) -> torch.Tensor: function generate_square_subsequent_mask (line 72) | def generate_square_subsequent_mask(size: int) -> torch.Tensor: FILE: lab06/text_recognizer/stems/image.py class ImageStem (line 5) | class ImageStem: method __init__ (line 23) | def __init__(self): method __call__ (line 28) | def __call__(self, img): class MNISTStem (line 38) | class MNISTStem(ImageStem): method __init__ (line 41) | def __init__(self): FILE: lab06/text_recognizer/stems/line.py class LineStem (line 11) | class LineStem(ImageStem): method __init__ (line 14) | def __init__(self, augment=False, color_jitter_kwargs=None, random_aff... class IAMLineStem (line 37) | class IAMLineStem(ImageStem): method __init__ (line 40) | def __init__(self, augment=False, color_jitter_kwargs=None, random_aff... FILE: lab06/text_recognizer/stems/paragraph.py class ParagraphStem (line 14) | class ParagraphStem(ImageStem): method __init__ (line 17) | def __init__( FILE: lab06/text_recognizer/tests/test_callback_utils.py function test_check_and_warn_simple (line 11) | def test_check_and_warn_simple(): function test_check_and_warn_tblogger (line 23) | def test_check_and_warn_tblogger(): function test_check_and_warn_wandblogger (line 32) | def test_check_and_warn_wandblogger(): FILE: lab06/text_recognizer/tests/test_iam.py function test_iam_parsed_lines (line 5) | def test_iam_parsed_lines(): function test_iam_data_splits (line 13) | def test_iam_data_splits(): FILE: lab06/text_recognizer/util.py function to_categorical (line 17) | def to_categorical(y, num_classes): function read_image_pil (line 22) | def read_image_pil(image_uri: Union[Path, str], grayscale=False) -> Image: function read_image_pil_file (line 27) | def read_image_pil_file(image_file, grayscale=False) -> Image: function temporary_working_directory (line 37) | def temporary_working_directory(working_dir: Union[str, Path]): function compute_sha256 (line 47) | def compute_sha256(filename: Union[Path, str]): class TqdmUpTo (line 53) | class TqdmUpTo(tqdm): method update_to (line 56) | def update_to(self, blocks=1, bsize=1, tsize=None): function download_url (line 72) | def download_url(url, filename): FILE: lab06/training/run_experiment.py function _setup_parser (line 21) | def _setup_parser(): function _ensure_logging_dir (line 87) | def _ensure_logging_dir(experiment_dir): function main (line 92) | def main(): FILE: lab06/training/util.py function import_class (line 9) | def import_class(module_and_class_name: str) -> type: function setup_data_and_model_from_args (line 17) | def setup_data_and_model_from_args(args: argparse.Namespace): FILE: lab07/api_serverless/api.py function handler (line 12) | def handler(event, _context): function _load_image (line 30) | def _load_image(event): function _from_string (line 46) | def _from_string(event): FILE: lab07/app_gradio/app.py function main (line 28) | def main(args): function make_frontend (line 41) | def make_frontend( class PredictorBackend (line 73) | class PredictorBackend: method __init__ (line 81) | def __init__(self, url=None): method run (line 89) | def run(self, image): method _predict_with_metrics (line 94) | def _predict_with_metrics(self, image): method _predict_from_endpoint (line 107) | def _predict_from_endpoint(self, image): method _log_inference (line 133) | def _log_inference(self, pred, metrics): function _load_readme (line 139) | def _load_readme(with_logging=False): function _make_parser (line 149) | def _make_parser(): FILE: lab07/app_gradio/tests/test_app.py function test_local_run (line 16) | def test_local_run(): FILE: lab07/text_recognizer/callbacks/imtotext.py class ImageToTextTableLogger (line 14) | class ImageToTextTableLogger(pl.Callback): method __init__ (line 17) | def __init__(self, max_images_to_log=32, on_train=True): method on_train_batch_end (line 24) | def on_train_batch_end(self, trainer, module, output, batch, batch_idx): method on_validation_batch_end (line 33) | def on_validation_batch_end(self, trainer, module, output, batch, batc... method _log_image_text_table (line 40) | def _log_image_text_table(self, trainer, output, batch, key): method has_metrics (line 55) | def has_metrics(self, output): class ImageToTextCaptionLogger (line 59) | class ImageToTextCaptionLogger(pl.Callback): method __init__ (line 62) | def __init__(self, max_images_to_log=32, on_train=True): method on_train_batch_end (line 69) | def on_train_batch_end(self, trainer, module, output, batch, batch_idx): method on_validation_batch_end (line 77) | def on_validation_batch_end(self, trainer, module, output, batch, batc... method on_test_batch_end (line 85) | def on_test_batch_end(self, trainer, module, output, batch, batch_idx,... method _log_image_text_caption (line 92) | def _log_image_text_caption(self, trainer, output, batch, key): method has_metrics (line 102) | def has_metrics(self, output): FILE: lab07/text_recognizer/callbacks/model.py class ModelSizeLogger (line 19) | class ModelSizeLogger(pl.Callback): method __init__ (line 22) | def __init__(self, print_size=True): method on_fit_start (line 27) | def on_fit_start(self, trainer, module): method _run (line 30) | def _run(self, trainer, module): method get_model_disksize (line 43) | def get_model_disksize(module): class GraphLogger (line 51) | class GraphLogger(pl.Callback): method __init__ (line 54) | def __init__(self, output_key="logits"): method on_train_batch_end (line 62) | def on_train_batch_end(self, trainer, module, outputs, batch, batch_id... method log_graph (line 72) | def log_graph(trainer, module, outputs): function count_params (line 84) | def count_params(module): FILE: lab07/text_recognizer/callbacks/optim.py class LearningRateMonitor (line 6) | class LearningRateMonitor(pl.callbacks.LearningRateMonitor): method _add_prefix (line 13) | def _add_prefix(self, *args, **kwargs) -> str: FILE: lab07/text_recognizer/callbacks/util.py function check_and_warn (line 6) | def check_and_warn(logger, attribute, feature): function warn_no_attribute (line 12) | def warn_no_attribute(blocked_feature, missing_attribute): FILE: lab07/text_recognizer/data/base_data_module.py function load_and_print_info (line 16) | def load_and_print_info(data_module_class) -> None: function _download_raw_dataset (line 27) | def _download_raw_dataset(metadata: Dict, dl_dirname: Path) -> Path: class BaseDataModule (line 51) | class BaseDataModule(pl.LightningDataModule): method __init__ (line 57) | def __init__(self, args: argparse.Namespace = None) -> None: method data_dirname (line 74) | def data_dirname(cls): method add_to_argparse (line 78) | def add_to_argparse(parser): method config (line 93) | def config(self): method prepare_data (line 97) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 104) | def setup(self, stage: Optional[str] = None) -> None: method train_dataloader (line 111) | def train_dataloader(self): method val_dataloader (line 120) | def val_dataloader(self): method test_dataloader (line 129) | def test_dataloader(self): FILE: lab07/text_recognizer/data/emnist.py class EMNIST (line 32) | class EMNIST(BaseDataModule): method __init__ (line 43) | def __init__(self, args=None): method prepare_data (line 52) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 56) | def setup(self, stage: str = None) -> None: method __repr__ (line 71) | def __repr__(self): function _download_and_process_emnist (line 85) | def _download_and_process_emnist(): function _process_raw_dataset (line 91) | def _process_raw_dataset(filename: str, dirname: Path): function _sample_to_balance (line 133) | def _sample_to_balance(x, y): function _augment_emnist_characters (line 148) | def _augment_emnist_characters(characters: Sequence[str]) -> Sequence[str]: FILE: lab07/text_recognizer/data/emnist_lines.py class EMNISTLines (line 28) | class EMNISTLines(BaseDataModule): method __init__ (line 31) | def __init__( method add_to_argparse (line 55) | def add_to_argparse(parser): method data_filename (line 79) | def data_filename(self): method prepare_data (line 85) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 93) | def setup(self, stage: str = None) -> None: method __repr__ (line 111) | def __repr__(self) -> str: method _generate_data (line 132) | def _generate_data(self, split: str) -> None: function get_samples_by_char (line 168) | def get_samples_by_char(samples, labels, mapping): function select_letter_samples_for_string (line 175) | def select_letter_samples_for_string(string, samples_by_char, char_shape... function construct_image_from_string (line 187) | def construct_image_from_string( function create_dataset_of_images (line 202) | def create_dataset_of_images(N, samples_by_char, sentence_generator, min... function convert_strings_to_labels (line 212) | def convert_strings_to_labels( FILE: lab07/text_recognizer/data/fake_images.py class FakeImageData (line 15) | class FakeImageData(BaseDataModule): method __init__ (line 18) | def __init__(self, args: argparse.Namespace = None): method add_to_argparse (line 28) | def add_to_argparse(parser): method setup (line 36) | def setup(self, stage: str = None) -> None: FILE: lab07/text_recognizer/data/iam.py class IAM (line 22) | class IAM: method __init__ (line 40) | def __init__(self): method prepare_data (line 43) | def prepare_data(self): method load_image (line 49) | def load_image(self, id: str) -> Image.Image: method __repr__ (line 62) | def __repr__(self): method all_ids (line 74) | def all_ids(self): method ids_by_split (line 79) | def ids_by_split(self): method split_by_id (line 83) | def split_by_id(self): method train_ids (line 91) | def train_ids(self): method test_ids (line 96) | def test_ids(self): method xml_filenames (line 101) | def xml_filenames(self) -> List[Path]: method validation_ids (line 106) | def validation_ids(self): method form_filenames (line 113) | def form_filenames(self) -> List[Path]: method xml_filenames_by_id (line 118) | def xml_filenames_by_id(self): method form_filenames_by_id (line 123) | def form_filenames_by_id(self): method line_strings_by_id (line 128) | def line_strings_by_id(self): method line_regions_by_id (line 133) | def line_regions_by_id(self): method paragraph_string_by_id (line 138) | def paragraph_string_by_id(self): method paragraph_region_by_id (line 143) | def paragraph_region_by_id(self): function _extract_raw_dataset (line 156) | def _extract_raw_dataset(filename: Path, dirname: Path) -> None: function _get_ids_from_lwitlrt_split_file (line 163) | def _get_ids_from_lwitlrt_split_file(filename: str) -> List[str]: function _get_line_strings_from_xml_file (line 172) | def _get_line_strings_from_xml_file(filename: str) -> List[str]: function _get_text_from_xml_element (line 178) | def _get_text_from_xml_element(xml_element: Any) -> str: function _get_line_regions_from_xml_file (line 183) | def _get_line_regions_from_xml_file(filename: str) -> List[Dict[str, int]]: function _get_line_elements_from_xml_file (line 210) | def _get_line_elements_from_xml_file(filename: str) -> List[Any]: function _get_region_from_xml_element (line 216) | def _get_region_from_xml_element(xml_elem: Any, xml_path: str) -> Option... FILE: lab07/text_recognizer/data/iam_lines.py class IAMLines (line 24) | class IAMLines(BaseDataModule): method __init__ (line 27) | def __init__(self, args: argparse.Namespace = None): method add_to_argparse (line 38) | def add_to_argparse(parser): method prepare_data (line 43) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 64) | def setup(self, stage: str = None) -> None: method __repr__ (line 91) | def __repr__(self) -> str: function generate_line_crops_and_labels (line 114) | def generate_line_crops_and_labels(iam: IAM, split: str, scale_factor=IM... function save_images_and_labels (line 131) | def save_images_and_labels(crops: Sequence[Image.Image], labels: Sequenc... function load_processed_crops_and_labels (line 140) | def load_processed_crops_and_labels(split: str, data_dirname: Path): function load_processed_line_crops (line 148) | def load_processed_line_crops(split: str, data_dirname: Path): function load_processed_line_labels (line 155) | def load_processed_line_labels(split: str, data_dirname: Path): FILE: lab07/text_recognizer/data/iam_original_and_synthetic_paragraphs.py class IAMOriginalAndSyntheticParagraphs (line 11) | class IAMOriginalAndSyntheticParagraphs(BaseDataModule): method __init__ (line 14) | def __init__(self, args: argparse.Namespace = None): method add_to_argparse (line 26) | def add_to_argparse(parser): method prepare_data (line 32) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 36) | def setup(self, stage: str = None) -> None: method __repr__ (line 47) | def __repr__(self) -> str: FILE: lab07/text_recognizer/data/iam_paragraphs.py class IAMParagraphs (line 24) | class IAMParagraphs(BaseDataModule): method __init__ (line 27) | def __init__(self, args: argparse.Namespace = None): method add_to_argparse (line 41) | def add_to_argparse(parser): method prepare_data (line 46) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 75) | def setup(self, stage: str = None) -> None: method __repr__ (line 91) | def __repr__(self) -> str: function validate_input_and_output_dimensions (line 114) | def validate_input_and_output_dimensions( function get_paragraph_crops_and_labels (line 127) | def get_paragraph_crops_and_labels( function save_crops_and_labels (line 143) | def save_crops_and_labels(crops: Dict[str, Image.Image], labels: Dict[st... function load_processed_crops_and_labels (line 154) | def load_processed_crops_and_labels(split: str) -> Tuple[Sequence[Image.... function get_dataset_properties (line 167) | def get_dataset_properties() -> dict: function _labels_filename (line 188) | def _labels_filename(split: str) -> Path: function _crop_filename (line 193) | def _crop_filename(id_: str, split: str) -> Path: function _num_lines (line 198) | def _num_lines(label: str) -> int: FILE: lab07/text_recognizer/data/iam_synthetic_paragraphs.py class IAMSyntheticParagraphs (line 29) | class IAMSyntheticParagraphs(IAMParagraphs): method __init__ (line 32) | def __init__(self, args: argparse.Namespace = None): method prepare_data (line 39) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 58) | def setup(self, stage: str = None) -> None: method _load_processed_crops_and_labels (line 73) | def _load_processed_crops_and_labels(self): method __repr__ (line 79) | def __repr__(self) -> str: method add_to_argparse (line 98) | def add_to_argparse(parser): class IAMSyntheticParagraphsDataset (line 103) | class IAMSyntheticParagraphsDataset(torch.utils.data.Dataset): method __init__ (line 106) | def __init__( method __len__ (line 131) | def __len__(self) -> int: method _set_seed (line 135) | def _set_seed(self, seed): method __getitem__ (line 141) | def __getitem__(self, index: int) -> Tuple[Any, Any]: function join_line_crops_to_form_paragraph (line 169) | def join_line_crops_to_form_paragraph(line_crops: Sequence[Image.Image])... FILE: lab07/text_recognizer/data/mnist.py class MNIST (line 12) | class MNIST(BaseDataModule): method __init__ (line 15) | def __init__(self, args: argparse.Namespace) -> None: method prepare_data (line 23) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 28) | def setup(self, stage=None) -> None: FILE: lab07/text_recognizer/data/sentence_generator.py class SentenceGenerator (line 15) | class SentenceGenerator: method __init__ (line 18) | def __init__(self, max_length: Optional[int] = None): method generate (line 23) | def generate(self, max_length: Optional[int] = None) -> str: method _get_end_ind_candidates (line 49) | def _get_end_ind_candidates(self, first_ind: int, start_ind: int, max_... function brown_text (line 58) | def brown_text(): function load_nltk_brown_corpus (line 67) | def load_nltk_brown_corpus(): FILE: lab07/text_recognizer/data/util.py class BaseDataset (line 11) | class BaseDataset(torch.utils.data.Dataset): method __init__ (line 28) | def __init__( method __len__ (line 43) | def __len__(self) -> int: method __getitem__ (line 47) | def __getitem__(self, index: int) -> Tuple[Any, Any]: function convert_strings_to_labels (line 70) | def convert_strings_to_labels(strings: Sequence[str], mapping: Dict[str,... function split_dataset (line 84) | def split_dataset(base_dataset: BaseDataset, fraction: float, seed: int)... function resize_image (line 96) | def resize_image(image: Image.Image, scale_factor: int) -> Image.Image: FILE: lab07/text_recognizer/lit_models/base.py class BaseLitModel (line 17) | class BaseLitModel(pl.LightningModule): method __init__ (line 22) | def __init__(self, model, args: argparse.Namespace = None): method add_to_argparse (line 48) | def add_to_argparse(parser): method configure_optimizers (line 56) | def configure_optimizers(self): method forward (line 65) | def forward(self, x): method predict (line 68) | def predict(self, x): method training_step (line 72) | def training_step(self, batch, batch_idx): method _run_on_batch (line 84) | def _run_on_batch(self, batch, with_preds=False): method validation_step (line 91) | def validation_step(self, batch, batch_idx): method test_step (line 103) | def test_step(self, batch, batch_idx): method add_on_first_batch (line 110) | def add_on_first_batch(self, metrics, outputs, batch_idx): method add_on_logged_batches (line 114) | def add_on_logged_batches(self, metrics, outputs): method is_logged_batch (line 118) | def is_logged_batch(self): class BaseImageToTextLitModel (line 125) | class BaseImageToTextLitModel(BaseLitModel): # pylint: disable=too-many... method __init__ (line 128) | def __init__(self, model, args: argparse.Namespace = None): FILE: lab07/text_recognizer/lit_models/metrics.py class CharacterErrorRate (line 8) | class CharacterErrorRate(torchmetrics.CharErrorRate): method __init__ (line 11) | def __init__(self, ignore_tokens: Sequence[int], *args): method update (line 15) | def update(self, preds: torch.Tensor, targets: torch.Tensor): # type:... function test_character_error_rate (line 21) | def test_character_error_rate(): FILE: lab07/text_recognizer/lit_models/transformer.py class TransformerLitModel (line 10) | class TransformerLitModel(BaseImageToTextLitModel): method __init__ (line 18) | def __init__(self, model, args=None): method forward (line 22) | def forward(self, x): method teacher_forward (line 25) | def teacher_forward(self, x: torch.Tensor, y: torch.Tensor) -> torch.T... method training_step (line 44) | def training_step(self, batch, batch_idx): method validation_step (line 59) | def validation_step(self, batch, batch_idx): method test_step (line 80) | def test_step(self, batch, batch_idx): method map (line 101) | def map(self, ks: Sequence[int], ignore: bool = True) -> str: method batchmap (line 108) | def batchmap(self, ks: Sequence[Sequence[int]], ignore=True) -> List[s... method get_preds (line 112) | def get_preds(self, logitlikes: torch.Tensor, replace_after_end: bool ... FILE: lab07/text_recognizer/lit_models/util.py function first_appearance (line 6) | def first_appearance(x: torch.Tensor, element: Union[int, float], dim: i... function replace_after (line 47) | def replace_after(x: torch.Tensor, element: Union[int, float], replace: ... FILE: lab07/text_recognizer/models/cnn.py class ConvBlock (line 15) | class ConvBlock(nn.Module): method __init__ (line 20) | def __init__(self, input_channels: int, output_channels: int) -> None: method forward (line 25) | def forward(self, x: torch.Tensor) -> torch.Tensor: class CNN (line 43) | class CNN(nn.Module): method __init__ (line 46) | def __init__(self, data_config: Dict[str, Any], args: argparse.Namespa... method forward (line 75) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 101) | def add_to_argparse(parser): FILE: lab07/text_recognizer/models/line_cnn.py class ConvBlock (line 21) | class ConvBlock(nn.Module): method __init__ (line 26) | def __init__( method forward (line 38) | def forward(self, x: torch.Tensor) -> torch.Tensor: class LineCNN (line 56) | class LineCNN(nn.Module): method __init__ (line 61) | def __init__( method _init_weights (line 100) | def _init_weights(self): method forward (line 119) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 146) | def add_to_argparse(parser): FILE: lab07/text_recognizer/models/line_cnn_simple.py class LineCNNSimple (line 16) | class LineCNNSimple(nn.Module): method __init__ (line 19) | def __init__( method forward (line 38) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 73) | def add_to_argparse(parser): FILE: lab07/text_recognizer/models/line_cnn_transformer.py class LineCNNTransformer (line 20) | class LineCNNTransformer(nn.Module): method __init__ (line 23) | def __init__( method init_weights (line 65) | def init_weights(self): method encode (line 71) | def encode(self, x: torch.Tensor) -> torch.Tensor: method decode (line 90) | def decode(self, x, y): method forward (line 117) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 150) | def add_to_argparse(parser): FILE: lab07/text_recognizer/models/mlp.py class MLP (line 14) | class MLP(nn.Module): method __init__ (line 17) | def __init__( method forward (line 39) | def forward(self, x): method add_to_argparse (line 51) | def add_to_argparse(parser): FILE: lab07/text_recognizer/models/resnet_transformer.py class ResnetTransformer (line 21) | class ResnetTransformer(nn.Module): method __init__ (line 24) | def __init__( method forward (line 75) | def forward(self, x: torch.Tensor) -> torch.Tensor: method init_weights (line 111) | def init_weights(self): method encode (line 123) | def encode(self, x: torch.Tensor) -> torch.Tensor: method decode (line 147) | def decode(self, x, y): method add_to_argparse (line 179) | def add_to_argparse(parser): FILE: lab07/text_recognizer/models/transformer_util.py class PositionalEncodingImage (line 9) | class PositionalEncodingImage(nn.Module): method __init__ (line 16) | def __init__(self, d_model: int, max_h: int = 2000, max_w: int = 2000,... method make_pe (line 26) | def make_pe(d_model: int, max_h: int, max_w: int) -> torch.Tensor: method forward (line 36) | def forward(self, x: Tensor) -> Tensor: class PositionalEncoding (line 44) | class PositionalEncoding(torch.nn.Module): method __init__ (line 47) | def __init__(self, d_model: int, dropout: float = 0.1, max_len: int = ... method make_pe (line 56) | def make_pe(d_model: int, max_len: int) -> torch.Tensor: method forward (line 65) | def forward(self, x: torch.Tensor) -> torch.Tensor: function generate_square_subsequent_mask (line 72) | def generate_square_subsequent_mask(size: int) -> torch.Tensor: FILE: lab07/text_recognizer/paragraph_text_recognizer.py class ParagraphTextRecognizer (line 26) | class ParagraphTextRecognizer: method __init__ (line 29) | def __init__(self, model_path=None): method predict (line 38) | def predict(self, image: Union[str, Path, Image.Image]) -> str: function convert_y_label_to_string (line 51) | def convert_y_label_to_string(y: torch.Tensor, mapping: Sequence[str], i... function main (line 55) | def main(): FILE: lab07/text_recognizer/stems/image.py class ImageStem (line 5) | class ImageStem: method __init__ (line 23) | def __init__(self): method __call__ (line 28) | def __call__(self, img): class MNISTStem (line 38) | class MNISTStem(ImageStem): method __init__ (line 41) | def __init__(self): FILE: lab07/text_recognizer/stems/line.py class LineStem (line 11) | class LineStem(ImageStem): method __init__ (line 14) | def __init__(self, augment=False, color_jitter_kwargs=None, random_aff... class IAMLineStem (line 37) | class IAMLineStem(ImageStem): method __init__ (line 40) | def __init__(self, augment=False, color_jitter_kwargs=None, random_aff... FILE: lab07/text_recognizer/stems/paragraph.py class ParagraphStem (line 14) | class ParagraphStem(ImageStem): method __init__ (line 17) | def __init__( FILE: lab07/text_recognizer/tests/test_callback_utils.py function test_check_and_warn_simple (line 11) | def test_check_and_warn_simple(): function test_check_and_warn_tblogger (line 23) | def test_check_and_warn_tblogger(): function test_check_and_warn_wandblogger (line 32) | def test_check_and_warn_wandblogger(): FILE: lab07/text_recognizer/tests/test_iam.py function test_iam_parsed_lines (line 5) | def test_iam_parsed_lines(): function test_iam_data_splits (line 13) | def test_iam_data_splits(): FILE: lab07/text_recognizer/util.py function to_categorical (line 17) | def to_categorical(y, num_classes): function read_image_pil (line 22) | def read_image_pil(image_uri: Union[Path, str], grayscale=False) -> Image: function read_image_pil_file (line 27) | def read_image_pil_file(image_file, grayscale=False) -> Image: function temporary_working_directory (line 37) | def temporary_working_directory(working_dir: Union[str, Path]): function encode_b64_image (line 47) | def encode_b64_image(image, format="png"): function compute_sha256 (line 55) | def compute_sha256(filename: Union[Path, str]): class TqdmUpTo (line 61) | class TqdmUpTo(tqdm): method update_to (line 64) | def update_to(self, blocks=1, bsize=1, tsize=None): function download_url (line 80) | def download_url(url, filename): FILE: lab07/training/cleanup_artifacts.py function _setup_parser (line 30) | def _setup_parser(): function main (line 87) | def main(args): function clean_run_artifacts (line 101) | def clean_run_artifacts(run, selector, protect_aliases=True, verbose=Fal... function remove_artifact (line 108) | def remove_artifact(artifact, protect_aliases, verbose=False, dryrun=True): function _get_runs (line 117) | def _get_runs(project_path, run_ids=None, run_name_res=None, verbose=Fal... function _get_run_by_id (line 134) | def _get_run_by_id(project_path, run_id, verbose=False): function _get_runs_by_name_re (line 142) | def _get_runs_by_name_re(project_path, run_name_re, verbose=False): function _get_selector_from (line 152) | def _get_selector_from(args, verbose=False): function _get_entity_from (line 173) | def _get_entity_from(args, verbose=False): FILE: lab07/training/run_experiment.py function _setup_parser (line 21) | def _setup_parser(): function _ensure_logging_dir (line 87) | def _ensure_logging_dir(experiment_dir): function main (line 92) | def main(): FILE: lab07/training/stage_model.py function main (line 45) | def main(args): function find_artifact (line 85) | def find_artifact(entity: str, project: str, type: str, alias: str, run=... function get_logging_run (line 115) | def get_logging_run(artifact): function print_info (line 120) | def print_info(artifact, run=None): function get_checkpoint_metadata (line 134) | def get_checkpoint_metadata(run, checkpoint): function download_artifact (line 148) | def download_artifact(artifact_path, target_directory): function load_model_from_checkpoint (line 159) | def load_model_from_checkpoint(ckpt_metadata, directory): function save_model_to_torchscript (line 173) | def save_model_to_torchscript(model, directory): function upload_staged_model (line 179) | def upload_staged_model(staged_at, from_directory): function _find_artifact_run (line 184) | def _find_artifact_run(entity, project, type, run, alias): function _find_artifact_project (line 196) | def _find_artifact_project(entity, project, type, alias): function _get_entity_from (line 215) | def _get_entity_from(args): function _setup_parser (line 225) | def _setup_parser(): FILE: lab07/training/util.py function import_class (line 9) | def import_class(module_and_class_name: str) -> type: function setup_data_and_model_from_args (line 17) | def setup_data_and_model_from_args(args: argparse.Namespace): FILE: lab08/api_serverless/api.py function handler (line 12) | def handler(event, _context): function _load_image (line 30) | def _load_image(event): function _from_string (line 46) | def _from_string(event): FILE: lab08/app_gradio/app.py function main (line 34) | def main(args): function make_frontend (line 45) | def make_frontend( class PredictorBackend (line 96) | class PredictorBackend: method __init__ (line 104) | def __init__(self, url=None): method run (line 112) | def run(self, image): method _predict_with_metrics (line 117) | def _predict_with_metrics(self, image): method _predict_from_endpoint (line 130) | def _predict_from_endpoint(self, image): method _log_inference (line 156) | def _log_inference(self, pred, metrics): function _load_readme (line 162) | def _load_readme(with_logging=False): function _make_parser (line 172) | def _make_parser(): FILE: lab08/app_gradio/flagging.py class GantryImageToTextLogger (line 13) | class GantryImageToTextLogger(gr.FlaggingCallback): method __init__ (line 16) | def __init__(self, application: str, version: Union[int, str, None] = ... method setup (line 50) | def setup(self, components: List[Component], flagging_dir: str): method flag (line 58) | def flag(self, flag_data, flag_option=None, flag_index=None, username=... method _to_gantry (line 74) | def _to_gantry(self, input_image_url, output_text, feedback): method _to_s3 (line 80) | def _to_s3(self, image_bytes, key=None, filetype=None): method _find_image_and_text_components (line 91) | def _find_image_and_text_components(self, components: List[Component]): function get_api_key (line 107) | def get_api_key() -> Optional[str]: FILE: lab08/app_gradio/s3_util.py function get_or_create_bucket (line 13) | def get_or_create_bucket(name): function _create_bucket (line 31) | def _create_bucket(name): function make_key (line 42) | def make_key(fileobj, filetype=None): function make_unique_bucket_name (line 51) | def make_unique_bucket_name(prefix, seed): function get_url_of (line 57) | def get_url_of(bucket, key=None): function get_uri_of (line 68) | def get_uri_of(bucket, key=None): function enable_bucket_versioning (line 79) | def enable_bucket_versioning(bucket): function add_access_policy (line 88) | def add_access_policy(bucket): function _get_policy (line 94) | def _get_policy(bucket_name): function make_identifier (line 127) | def make_identifier(byte_data): function _get_region (line 136) | def _get_region(bucket): function _format_url (line 148) | def _format_url(bucket_name, region, key=None): function _format_uri (line 154) | def _format_uri(bucket_name, key=None): FILE: lab08/app_gradio/tests/test_app.py function test_local_run (line 16) | def test_local_run(): FILE: lab08/text_recognizer/callbacks/imtotext.py class ImageToTextTableLogger (line 14) | class ImageToTextTableLogger(pl.Callback): method __init__ (line 17) | def __init__(self, max_images_to_log=32, on_train=True): method on_train_batch_end (line 24) | def on_train_batch_end(self, trainer, module, output, batch, batch_idx): method on_validation_batch_end (line 33) | def on_validation_batch_end(self, trainer, module, output, batch, batc... method _log_image_text_table (line 40) | def _log_image_text_table(self, trainer, output, batch, key): method has_metrics (line 55) | def has_metrics(self, output): class ImageToTextCaptionLogger (line 59) | class ImageToTextCaptionLogger(pl.Callback): method __init__ (line 62) | def __init__(self, max_images_to_log=32, on_train=True): method on_train_batch_end (line 69) | def on_train_batch_end(self, trainer, module, output, batch, batch_idx): method on_validation_batch_end (line 77) | def on_validation_batch_end(self, trainer, module, output, batch, batc... method on_test_batch_end (line 85) | def on_test_batch_end(self, trainer, module, output, batch, batch_idx,... method _log_image_text_caption (line 92) | def _log_image_text_caption(self, trainer, output, batch, key): method has_metrics (line 102) | def has_metrics(self, output): FILE: lab08/text_recognizer/callbacks/model.py class ModelSizeLogger (line 19) | class ModelSizeLogger(pl.Callback): method __init__ (line 22) | def __init__(self, print_size=True): method on_fit_start (line 27) | def on_fit_start(self, trainer, module): method _run (line 30) | def _run(self, trainer, module): method get_model_disksize (line 43) | def get_model_disksize(module): class GraphLogger (line 51) | class GraphLogger(pl.Callback): method __init__ (line 54) | def __init__(self, output_key="logits"): method on_train_batch_end (line 62) | def on_train_batch_end(self, trainer, module, outputs, batch, batch_id... method log_graph (line 72) | def log_graph(trainer, module, outputs): function count_params (line 84) | def count_params(module): FILE: lab08/text_recognizer/callbacks/optim.py class LearningRateMonitor (line 6) | class LearningRateMonitor(pl.callbacks.LearningRateMonitor): method _add_prefix (line 13) | def _add_prefix(self, *args, **kwargs) -> str: FILE: lab08/text_recognizer/callbacks/util.py function check_and_warn (line 6) | def check_and_warn(logger, attribute, feature): function warn_no_attribute (line 12) | def warn_no_attribute(blocked_feature, missing_attribute): FILE: lab08/text_recognizer/data/base_data_module.py function load_and_print_info (line 16) | def load_and_print_info(data_module_class) -> None: function _download_raw_dataset (line 27) | def _download_raw_dataset(metadata: Dict, dl_dirname: Path) -> Path: class BaseDataModule (line 51) | class BaseDataModule(pl.LightningDataModule): method __init__ (line 57) | def __init__(self, args: argparse.Namespace = None) -> None: method data_dirname (line 74) | def data_dirname(cls): method add_to_argparse (line 78) | def add_to_argparse(parser): method config (line 93) | def config(self): method prepare_data (line 97) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 104) | def setup(self, stage: Optional[str] = None) -> None: method train_dataloader (line 111) | def train_dataloader(self): method val_dataloader (line 120) | def val_dataloader(self): method test_dataloader (line 129) | def test_dataloader(self): FILE: lab08/text_recognizer/data/emnist.py class EMNIST (line 32) | class EMNIST(BaseDataModule): method __init__ (line 43) | def __init__(self, args=None): method prepare_data (line 52) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 56) | def setup(self, stage: str = None) -> None: method __repr__ (line 71) | def __repr__(self): function _download_and_process_emnist (line 85) | def _download_and_process_emnist(): function _process_raw_dataset (line 91) | def _process_raw_dataset(filename: str, dirname: Path): function _sample_to_balance (line 133) | def _sample_to_balance(x, y): function _augment_emnist_characters (line 148) | def _augment_emnist_characters(characters: Sequence[str]) -> Sequence[str]: FILE: lab08/text_recognizer/data/emnist_lines.py class EMNISTLines (line 28) | class EMNISTLines(BaseDataModule): method __init__ (line 31) | def __init__( method add_to_argparse (line 55) | def add_to_argparse(parser): method data_filename (line 79) | def data_filename(self): method prepare_data (line 85) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 93) | def setup(self, stage: str = None) -> None: method __repr__ (line 111) | def __repr__(self) -> str: method _generate_data (line 132) | def _generate_data(self, split: str) -> None: function get_samples_by_char (line 168) | def get_samples_by_char(samples, labels, mapping): function select_letter_samples_for_string (line 175) | def select_letter_samples_for_string(string, samples_by_char, char_shape... function construct_image_from_string (line 187) | def construct_image_from_string( function create_dataset_of_images (line 202) | def create_dataset_of_images(N, samples_by_char, sentence_generator, min... function convert_strings_to_labels (line 212) | def convert_strings_to_labels( FILE: lab08/text_recognizer/data/fake_images.py class FakeImageData (line 15) | class FakeImageData(BaseDataModule): method __init__ (line 18) | def __init__(self, args: argparse.Namespace = None): method add_to_argparse (line 28) | def add_to_argparse(parser): method setup (line 36) | def setup(self, stage: str = None) -> None: FILE: lab08/text_recognizer/data/iam.py class IAM (line 22) | class IAM: method __init__ (line 40) | def __init__(self): method prepare_data (line 43) | def prepare_data(self): method load_image (line 49) | def load_image(self, id: str) -> Image.Image: method __repr__ (line 62) | def __repr__(self): method all_ids (line 74) | def all_ids(self): method ids_by_split (line 79) | def ids_by_split(self): method split_by_id (line 83) | def split_by_id(self): method train_ids (line 91) | def train_ids(self): method test_ids (line 96) | def test_ids(self): method xml_filenames (line 101) | def xml_filenames(self) -> List[Path]: method validation_ids (line 106) | def validation_ids(self): method form_filenames (line 113) | def form_filenames(self) -> List[Path]: method xml_filenames_by_id (line 118) | def xml_filenames_by_id(self): method form_filenames_by_id (line 123) | def form_filenames_by_id(self): method line_strings_by_id (line 128) | def line_strings_by_id(self): method line_regions_by_id (line 133) | def line_regions_by_id(self): method paragraph_string_by_id (line 138) | def paragraph_string_by_id(self): method paragraph_region_by_id (line 143) | def paragraph_region_by_id(self): function _extract_raw_dataset (line 156) | def _extract_raw_dataset(filename: Path, dirname: Path) -> None: function _get_ids_from_lwitlrt_split_file (line 163) | def _get_ids_from_lwitlrt_split_file(filename: str) -> List[str]: function _get_line_strings_from_xml_file (line 172) | def _get_line_strings_from_xml_file(filename: str) -> List[str]: function _get_text_from_xml_element (line 178) | def _get_text_from_xml_element(xml_element: Any) -> str: function _get_line_regions_from_xml_file (line 183) | def _get_line_regions_from_xml_file(filename: str) -> List[Dict[str, int]]: function _get_line_elements_from_xml_file (line 210) | def _get_line_elements_from_xml_file(filename: str) -> List[Any]: function _get_region_from_xml_element (line 216) | def _get_region_from_xml_element(xml_elem: Any, xml_path: str) -> Option... FILE: lab08/text_recognizer/data/iam_lines.py class IAMLines (line 24) | class IAMLines(BaseDataModule): method __init__ (line 27) | def __init__(self, args: argparse.Namespace = None): method add_to_argparse (line 38) | def add_to_argparse(parser): method prepare_data (line 43) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 64) | def setup(self, stage: str = None) -> None: method __repr__ (line 91) | def __repr__(self) -> str: function generate_line_crops_and_labels (line 114) | def generate_line_crops_and_labels(iam: IAM, split: str, scale_factor=IM... function save_images_and_labels (line 131) | def save_images_and_labels(crops: Sequence[Image.Image], labels: Sequenc... function load_processed_crops_and_labels (line 140) | def load_processed_crops_and_labels(split: str, data_dirname: Path): function load_processed_line_crops (line 148) | def load_processed_line_crops(split: str, data_dirname: Path): function load_processed_line_labels (line 155) | def load_processed_line_labels(split: str, data_dirname: Path): FILE: lab08/text_recognizer/data/iam_original_and_synthetic_paragraphs.py class IAMOriginalAndSyntheticParagraphs (line 11) | class IAMOriginalAndSyntheticParagraphs(BaseDataModule): method __init__ (line 14) | def __init__(self, args: argparse.Namespace = None): method add_to_argparse (line 26) | def add_to_argparse(parser): method prepare_data (line 32) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 36) | def setup(self, stage: str = None) -> None: method __repr__ (line 47) | def __repr__(self) -> str: FILE: lab08/text_recognizer/data/iam_paragraphs.py class IAMParagraphs (line 24) | class IAMParagraphs(BaseDataModule): method __init__ (line 27) | def __init__(self, args: argparse.Namespace = None): method add_to_argparse (line 41) | def add_to_argparse(parser): method prepare_data (line 46) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 75) | def setup(self, stage: str = None) -> None: method __repr__ (line 91) | def __repr__(self) -> str: function validate_input_and_output_dimensions (line 114) | def validate_input_and_output_dimensions( function get_paragraph_crops_and_labels (line 127) | def get_paragraph_crops_and_labels( function save_crops_and_labels (line 143) | def save_crops_and_labels(crops: Dict[str, Image.Image], labels: Dict[st... function load_processed_crops_and_labels (line 154) | def load_processed_crops_and_labels(split: str) -> Tuple[Sequence[Image.... function get_dataset_properties (line 167) | def get_dataset_properties() -> dict: function _labels_filename (line 188) | def _labels_filename(split: str) -> Path: function _crop_filename (line 193) | def _crop_filename(id_: str, split: str) -> Path: function _num_lines (line 198) | def _num_lines(label: str) -> int: FILE: lab08/text_recognizer/data/iam_synthetic_paragraphs.py class IAMSyntheticParagraphs (line 29) | class IAMSyntheticParagraphs(IAMParagraphs): method __init__ (line 32) | def __init__(self, args: argparse.Namespace = None): method prepare_data (line 39) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 58) | def setup(self, stage: str = None) -> None: method _load_processed_crops_and_labels (line 73) | def _load_processed_crops_and_labels(self): method __repr__ (line 79) | def __repr__(self) -> str: method add_to_argparse (line 98) | def add_to_argparse(parser): class IAMSyntheticParagraphsDataset (line 103) | class IAMSyntheticParagraphsDataset(torch.utils.data.Dataset): method __init__ (line 106) | def __init__( method __len__ (line 131) | def __len__(self) -> int: method _set_seed (line 135) | def _set_seed(self, seed): method __getitem__ (line 141) | def __getitem__(self, index: int) -> Tuple[Any, Any]: function join_line_crops_to_form_paragraph (line 169) | def join_line_crops_to_form_paragraph(line_crops: Sequence[Image.Image])... FILE: lab08/text_recognizer/data/mnist.py class MNIST (line 12) | class MNIST(BaseDataModule): method __init__ (line 15) | def __init__(self, args: argparse.Namespace) -> None: method prepare_data (line 23) | def prepare_data(self, *args, **kwargs) -> None: method setup (line 28) | def setup(self, stage=None) -> None: FILE: lab08/text_recognizer/data/sentence_generator.py class SentenceGenerator (line 15) | class SentenceGenerator: method __init__ (line 18) | def __init__(self, max_length: Optional[int] = None): method generate (line 23) | def generate(self, max_length: Optional[int] = None) -> str: method _get_end_ind_candidates (line 49) | def _get_end_ind_candidates(self, first_ind: int, start_ind: int, max_... function brown_text (line 58) | def brown_text(): function load_nltk_brown_corpus (line 67) | def load_nltk_brown_corpus(): FILE: lab08/text_recognizer/data/util.py class BaseDataset (line 11) | class BaseDataset(torch.utils.data.Dataset): method __init__ (line 28) | def __init__( method __len__ (line 43) | def __len__(self) -> int: method __getitem__ (line 47) | def __getitem__(self, index: int) -> Tuple[Any, Any]: function convert_strings_to_labels (line 70) | def convert_strings_to_labels(strings: Sequence[str], mapping: Dict[str,... function split_dataset (line 84) | def split_dataset(base_dataset: BaseDataset, fraction: float, seed: int)... function resize_image (line 96) | def resize_image(image: Image.Image, scale_factor: int) -> Image.Image: FILE: lab08/text_recognizer/lit_models/base.py class BaseLitModel (line 17) | class BaseLitModel(pl.LightningModule): method __init__ (line 22) | def __init__(self, model, args: argparse.Namespace = None): method add_to_argparse (line 48) | def add_to_argparse(parser): method configure_optimizers (line 56) | def configure_optimizers(self): method forward (line 65) | def forward(self, x): method predict (line 68) | def predict(self, x): method training_step (line 72) | def training_step(self, batch, batch_idx): method _run_on_batch (line 84) | def _run_on_batch(self, batch, with_preds=False): method validation_step (line 91) | def validation_step(self, batch, batch_idx): method test_step (line 103) | def test_step(self, batch, batch_idx): method add_on_first_batch (line 110) | def add_on_first_batch(self, metrics, outputs, batch_idx): method add_on_logged_batches (line 114) | def add_on_logged_batches(self, metrics, outputs): method is_logged_batch (line 118) | def is_logged_batch(self): class BaseImageToTextLitModel (line 125) | class BaseImageToTextLitModel(BaseLitModel): # pylint: disable=too-many... method __init__ (line 128) | def __init__(self, model, args: argparse.Namespace = None): FILE: lab08/text_recognizer/lit_models/metrics.py class CharacterErrorRate (line 8) | class CharacterErrorRate(torchmetrics.CharErrorRate): method __init__ (line 11) | def __init__(self, ignore_tokens: Sequence[int], *args): method update (line 15) | def update(self, preds: torch.Tensor, targets: torch.Tensor): # type:... function test_character_error_rate (line 21) | def test_character_error_rate(): FILE: lab08/text_recognizer/lit_models/transformer.py class TransformerLitModel (line 10) | class TransformerLitModel(BaseImageToTextLitModel): method __init__ (line 18) | def __init__(self, model, args=None): method forward (line 22) | def forward(self, x): method teacher_forward (line 25) | def teacher_forward(self, x: torch.Tensor, y: torch.Tensor) -> torch.T... method training_step (line 44) | def training_step(self, batch, batch_idx): method validation_step (line 59) | def validation_step(self, batch, batch_idx): method test_step (line 80) | def test_step(self, batch, batch_idx): method map (line 101) | def map(self, ks: Sequence[int], ignore: bool = True) -> str: method batchmap (line 108) | def batchmap(self, ks: Sequence[Sequence[int]], ignore=True) -> List[s... method get_preds (line 112) | def get_preds(self, logitlikes: torch.Tensor, replace_after_end: bool ... FILE: lab08/text_recognizer/lit_models/util.py function first_appearance (line 6) | def first_appearance(x: torch.Tensor, element: Union[int, float], dim: i... function replace_after (line 47) | def replace_after(x: torch.Tensor, element: Union[int, float], replace: ... FILE: lab08/text_recognizer/models/cnn.py class ConvBlock (line 15) | class ConvBlock(nn.Module): method __init__ (line 20) | def __init__(self, input_channels: int, output_channels: int) -> None: method forward (line 25) | def forward(self, x: torch.Tensor) -> torch.Tensor: class CNN (line 43) | class CNN(nn.Module): method __init__ (line 46) | def __init__(self, data_config: Dict[str, Any], args: argparse.Namespa... method forward (line 75) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 101) | def add_to_argparse(parser): FILE: lab08/text_recognizer/models/line_cnn.py class ConvBlock (line 21) | class ConvBlock(nn.Module): method __init__ (line 26) | def __init__( method forward (line 38) | def forward(self, x: torch.Tensor) -> torch.Tensor: class LineCNN (line 56) | class LineCNN(nn.Module): method __init__ (line 61) | def __init__( method _init_weights (line 100) | def _init_weights(self): method forward (line 119) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 146) | def add_to_argparse(parser): FILE: lab08/text_recognizer/models/line_cnn_simple.py class LineCNNSimple (line 16) | class LineCNNSimple(nn.Module): method __init__ (line 19) | def __init__( method forward (line 38) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 73) | def add_to_argparse(parser): FILE: lab08/text_recognizer/models/line_cnn_transformer.py class LineCNNTransformer (line 20) | class LineCNNTransformer(nn.Module): method __init__ (line 23) | def __init__( method init_weights (line 65) | def init_weights(self): method encode (line 71) | def encode(self, x: torch.Tensor) -> torch.Tensor: method decode (line 90) | def decode(self, x, y): method forward (line 117) | def forward(self, x: torch.Tensor) -> torch.Tensor: method add_to_argparse (line 150) | def add_to_argparse(parser): FILE: lab08/text_recognizer/models/mlp.py class MLP (line 14) | class MLP(nn.Module): method __init__ (line 17) | def __init__( method forward (line 39) | def forward(self, x): method add_to_argparse (line 51) | def add_to_argparse(parser): FILE: lab08/text_recognizer/models/resnet_transformer.py class ResnetTransformer (line 21) | class ResnetTransformer(nn.Module): method __init__ (line 24) | def __init__( method forward (line 75) | def forward(self, x: torch.Tensor) -> torch.Tensor: method init_weights (line 111) | def init_weights(self): method encode (line 123) | def encode(self, x: torch.Tensor) -> torch.Tensor: method decode (line 147) | def decode(self, x, y): method add_to_argparse (line 179) | def add_to_argparse(parser): FILE: lab08/text_recognizer/models/transformer_util.py class PositionalEncodingImage (line 9) | class PositionalEncodingImage(nn.Module): method __init__ (line 16) | def __init__(self, d_model: int, max_h: int = 2000, max_w: int = 2000,... method make_pe (line 26) | def make_pe(d_model: int, max_h: int, max_w: int) -> torch.Tensor: method forward (line 36) | def forward(self, x: Tensor) -> Tensor: class PositionalEncoding (line 44) | class PositionalEncoding(torch.nn.Module): method __init__ (line 47) | def __init__(self, d_model: int, dropout: float = 0.1, max_len: int = ... method make_pe (line 56) | def make_pe(d_model: int, max_len: int) -> torch.Tensor: method forward (line 65) | def forward(self, x: torch.Tensor) -> torch.Tensor: function generate_square_subsequent_mask (line 72) | def generate_square_subsequent_mask(size: int) -> torch.Tensor: FILE: lab08/text_recognizer/paragraph_text_recognizer.py class ParagraphTextRecognizer (line 26) | class ParagraphTextRecognizer: method __init__ (line 29) | def __init__(self, model_path=None): method predict (line 38) | def predict(self, image: Union[str, Path, Image.Image]) -> str: function convert_y_label_to_string (line 51) | def convert_y_label_to_string(y: torch.Tensor, mapping: Sequence[str], i... function main (line 55) | def main(): FILE: lab08/text_recognizer/stems/image.py class ImageStem (line 5) | class ImageStem: method __init__ (line 23) | def __init__(self): method __call__ (line 28) | def __call__(self, img): class MNISTStem (line 38) | class MNISTStem(ImageStem): method __init__ (line 41) | def __init__(self): FILE: lab08/text_recognizer/stems/line.py class LineStem (line 11) | class LineStem(ImageStem): method __init__ (line 14) | def __init__(self, augment=False, color_jitter_kwargs=None, random_aff... class IAMLineStem (line 37) | class IAMLineStem(ImageStem): method __init__ (line 40) | def __init__(self, augment=False, color_jitter_kwargs=None, random_aff... FILE: lab08/text_recognizer/stems/paragraph.py class ParagraphStem (line 14) | class ParagraphStem(ImageStem): method __init__ (line 17) | def __init__( FILE: lab08/text_recognizer/tests/test_callback_utils.py function test_check_and_warn_simple (line 11) | def test_check_and_warn_simple(): function test_check_and_warn_tblogger (line 23) | def test_check_and_warn_tblogger(): function test_check_and_warn_wandblogger (line 32) | def test_check_and_warn_wandblogger(): FILE: lab08/text_recognizer/tests/test_iam.py function test_iam_parsed_lines (line 5) | def test_iam_parsed_lines(): function test_iam_data_splits (line 13) | def test_iam_data_splits(): FILE: lab08/text_recognizer/util.py function to_categorical (line 17) | def to_categorical(y, num_classes): function read_image_pil (line 22) | def read_image_pil(image_uri: Union[Path, str], grayscale=False) -> Image: function read_image_pil_file (line 27) | def read_image_pil_file(image_file, grayscale=False) -> Image: function temporary_working_directory (line 37) | def temporary_working_directory(working_dir: Union[str, Path]): function read_b64_image (line 47) | def read_b64_image(b64_string, grayscale=False): function read_b64_string (line 56) | def read_b64_string(b64_string, return_data_type=False): function get_b64_filetype (line 66) | def get_b64_filetype(data_header): function split_and_validate_b64_string (line 72) | def split_and_validate_b64_string(b64_string): function encode_b64_image (line 81) | def encode_b64_image(image, format="png"): function compute_sha256 (line 89) | def compute_sha256(filename: Union[Path, str]): class TqdmUpTo (line 95) | class TqdmUpTo(tqdm): method update_to (line 98) | def update_to(self, blocks=1, bsize=1, tsize=None): function download_url (line 114) | def download_url(url, filename): FILE: lab08/training/cleanup_artifacts.py function _setup_parser (line 30) | def _setup_parser(): function main (line 87) | def main(args): function clean_run_artifacts (line 101) | def clean_run_artifacts(run, selector, protect_aliases=True, verbose=Fal... function remove_artifact (line 108) | def remove_artifact(artifact, protect_aliases, verbose=False, dryrun=True): function _get_runs (line 117) | def _get_runs(project_path, run_ids=None, run_name_res=None, verbose=Fal... function _get_run_by_id (line 134) | def _get_run_by_id(project_path, run_id, verbose=False): function _get_runs_by_name_re (line 142) | def _get_runs_by_name_re(project_path, run_name_re, verbose=False): function _get_selector_from (line 152) | def _get_selector_from(args, verbose=False): function _get_entity_from (line 173) | def _get_entity_from(args, verbose=False): FILE: lab08/training/run_experiment.py function _setup_parser (line 21) | def _setup_parser(): function _ensure_logging_dir (line 87) | def _ensure_logging_dir(experiment_dir): function main (line 92) | def main(): FILE: lab08/training/stage_model.py function main (line 45) | def main(args): function find_artifact (line 85) | def find_artifact(entity: str, project: str, type: str, alias: str, run=... function get_logging_run (line 115) | def get_logging_run(artifact): function print_info (line 120) | def print_info(artifact, run=None): function get_checkpoint_metadata (line 134) | def get_checkpoint_metadata(run, checkpoint): function download_artifact (line 148) | def download_artifact(artifact_path, target_directory): function load_model_from_checkpoint (line 159) | def load_model_from_checkpoint(ckpt_metadata, directory): function save_model_to_torchscript (line 173) | def save_model_to_torchscript(model, directory): function upload_staged_model (line 179) | def upload_staged_model(staged_at, from_directory): function _find_artifact_run (line 184) | def _find_artifact_run(entity, project, type, run, alias): function _find_artifact_project (line 196) | def _find_artifact_project(entity, project, type, alias): function _get_entity_from (line 215) | def _get_entity_from(args): function _setup_parser (line 225) | def _setup_parser(): FILE: lab08/training/util.py function import_class (line 9) | def import_class(module_and_class_name: str) -> type: function setup_data_and_model_from_args (line 17) | def setup_data_and_model_from_args(args: argparse.Namespace):