Skip to content

Commit

Permalink
no more need for backported importlib_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
mittagessen committed Jan 2, 2025
1 parent a6bcbd2 commit 08db477
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
5 changes: 3 additions & 2 deletions kraken/blla.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
import uuid
from typing import Any, Callable, Dict, List, Literal, Optional, Union

import importlib_resources
import numpy as np
import PIL
import shapely.geometry as geom
import torch
import torch.nn.functional as F
import torchvision.transforms as tf

from importlib import resources
from scipy.ndimage import gaussian_filter
from skimage.filters import sobel

Expand Down Expand Up @@ -295,7 +296,7 @@ def segment(im: PIL.Image.Image,
"""
if model is None:
logger.info('No segmentation model given. Loading default model.')
model = vgsl.TorchVGSLModel.load_model(importlib_resources.files(__name__).joinpath('blla.mlmodel'))
model = vgsl.TorchVGSLModel.load_model(resources.files(__name__).joinpath('blla.mlmodel'))

if isinstance(model, vgsl.TorchVGSLModel):
model = [model]
Expand Down
4 changes: 2 additions & 2 deletions kraken/ketos/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ def publish(ctx, metadata, access_token, private, model):
"""
import json

import importlib_resources
from importlib import resources
from jsonschema import validate
from jsonschema.exceptions import ValidationError

from kraken import repo
from kraken.lib import models
from kraken.lib.progress import KrakenDownloadProgressBar

ref = importlib_resources.files('kraken').joinpath('metadata.schema.json')
ref = resources.files('kraken').joinpath('metadata.schema.json')
with open(ref, 'rb') as fp:
schema = json.load(fp)

Expand Down
4 changes: 2 additions & 2 deletions kraken/kraken.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
from typing import IO, Any, Callable, Dict, List, Union, cast

import click
import importlib_resources
from PIL import Image
from importlib import resources
from rich.traceback import install

from kraken.lib import log
Expand All @@ -44,7 +44,7 @@
install(suppress=[click])

APP_NAME = 'kraken'
SEGMENTATION_DEFAULT_MODEL = importlib_resources.files(APP_NAME).joinpath('blla.mlmodel')
SEGMENTATION_DEFAULT_MODEL = resources.files(APP_NAME).joinpath('blla.mlmodel')
DEFAULT_MODEL = ['en_best.mlmodel']

# raise default max image size to 20k * 20k pixels
Expand Down
4 changes: 2 additions & 2 deletions kraken/lib/dataset/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
from functools import partial
from typing import Any, Dict, List, Sequence, Tuple, Union

import importlib_resources
import torch
import torch.nn.functional as F
from torchvision import transforms
from importlib import resources

from kraken.lib import functional_im_transforms as F_t
from kraken.lib.exceptions import KrakenInputException
Expand Down Expand Up @@ -319,7 +319,7 @@ def compute_confusions(algn1: Sequence[str], algn2: Sequence[str]):
script substitutions.
"""
counts: Dict[Tuple[str, str], int] = Counter()
ref = importlib_resources.files(__name__).joinpath('scripts.json')
ref = resources.files(__name__).joinpath('scripts.json')
with ref.open('rb') as fp:
script_map = json.load(fp)

Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ install_requires =
lightning~=2.4.0
torchmetrics>=1.1.0
threadpoolctl~=3.5.0
importlib-resources>=1.3.0
rich

[options.extras_require]
Expand Down

0 comments on commit 08db477

Please sign in to comment.