Skip to content

Commit

Permalink
Suppress CoreML converter warnings on import
Browse files Browse the repository at this point in the history
Resolves #536.
  • Loading branch information
mittagessen committed Sep 8, 2023
1 parent b89cfb2 commit 2f4d896
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
5 changes: 5 additions & 0 deletions kraken/lib/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
Layers for VGSL models
"""
import torch
import logging
import numpy as np

from typing import List, Tuple, Optional, Iterable
from torch.nn import Module, Sequential
from torch.nn import functional as F
from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence

logger = logging.getLogger('coremltools')
logger.setLevel(logging.ERROR)
from coremltools.proto import NeuralNetwork_pb2
logger.setLevel(logging.WARNING)

# all tensors are ordered NCHW, the "feature" dimension is C, so the output of
# an LSTM will be put into C same as the filters of a CNN.
Expand Down
11 changes: 3 additions & 8 deletions kraken/lib/vgsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@
from kraken.lib.codec import PytorchCodec
from kraken.lib.exceptions import KrakenInvalidModelException

# filter out coreml warnings coming from their conversion routines (which we don't use).
with warnings.catch_warnings():
warnings.filterwarnings(action='ignore', message='has not been tested with coremltools')
warnings.filterwarnings(action='ignore', message='is not supported')

from coremltools.models import MLModel
from coremltools.models import datatypes
from coremltools.models.neural_network import NeuralNetworkBuilder
from coremltools.models import MLModel
from coremltools.models import datatypes
from coremltools.models.neural_network import NeuralNetworkBuilder

from google.protobuf.message import DecodeError

Expand Down

0 comments on commit 2f4d896

Please sign in to comment.