Skip to content

Commit

Permalink
Merge pull request #160 from Kitware/main
Browse files Browse the repository at this point in the history
cut 0.7.0
  • Loading branch information
PaulHax authored Dec 17, 2024
2 parents 94b25b1 + b5aa743 commit 6e6ab8a
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 58 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/create_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Create Release

on:
workflow_dispatch:
push:
branches:
- release

jobs:
release:
Expand Down Expand Up @@ -45,3 +48,11 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.release.outputs.tag }}

- name: Merge release -> main
uses: devmasx/merge-branch@master
with:
type: now
target_branch: main
message: Merge release into main
github_token: ${{ secrets.GITHUB_TOKEN }}
26 changes: 0 additions & 26 deletions .github/workflows/sync_branches.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ dependencies = [
"transformers",
"datasets[vision]",
"umap-learn",
"nrtk[headless]>=0.12.0",
"nrtk[headless]>=0.12.0,<=0.16.0",
"trame-annotations>=0.4.0",
]

Expand Down
42 changes: 25 additions & 17 deletions src/nrtk_explorer/app/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from nrtk_explorer.library.filtering import FilterProtocol
from nrtk_explorer.library.dataset import get_dataset, expand_hugging_face_datasets
from nrtk_explorer.library.debounce import debounce
from nrtk_explorer.library.app_config import process_config


from nrtk_explorer.app.images.images import Images
from nrtk_explorer.app.embeddings import EmbeddingsApp
Expand Down Expand Up @@ -38,36 +40,42 @@
# Engine class
# ---------------------------------------------------------

config_options = {
"dataset": {
"flags": ["--dataset"],
"params": {
"nargs": "+",
"default": DEFAULT_DATASETS,
"help": "Path to the JSON file describing the image dataset",
},
},
"download": {
"flags": ["--download"],
"params": {
"action": "store_true",
"default": False,
"help": "Download Hugging Face Hub datasets instead of streaming them",
},
},
}


class Engine(Applet):
def __init__(self, server=None):
def __init__(self, server=None, **kwargs):
super().__init__(server)

self.server.cli.add_argument(
"--dataset",
nargs="+",
default=DEFAULT_DATASETS,
help="Path to the JSON file describing the image dataset",
)

self.server.cli.add_argument(
"--download",
action="store_true",
default=False,
help="Download Hugging Face Hub datasets instead of streaming them",
)
config = process_config(self.server.cli, config_options, **kwargs)

known_args, _ = self.server.cli.parse_known_args()
dataset_identifiers = expand_hugging_face_datasets(
known_args.dataset, not known_args.download
config["dataset"], not config["download"]
)
self.input_paths = dataset_identifiers
self.state.current_dataset = self.input_paths[0]

images = Images(server=self.server)

self._transforms_app = TransformsApp(
server=self.server.create_child_server(), images=images
server=self.server.create_child_server(), images=images, **kwargs
)

self._embeddings_app = EmbeddingsApp(
Expand Down
33 changes: 20 additions & 13 deletions src/nrtk_explorer/app/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
import nrtk_explorer.library.nrtk_transforms as nrtk_trans
import nrtk_explorer.library.yaml_transforms as nrtk_yaml
from nrtk_explorer.library import object_detector
from nrtk_explorer.app.applet import Applet
from nrtk_explorer.app.parameters import ParametersApp
from nrtk_explorer.app.images.image_meta import update_image_meta, dataset_id_to_meta
from nrtk_explorer.library.app_config import process_config
from nrtk_explorer.library.scoring import (
compute_score,
)
from nrtk_explorer.app.trame_utils import change_checker, delete_state

from nrtk_explorer.app.applet import Applet
from nrtk_explorer.app.parameters import ParametersApp
from nrtk_explorer.app.images.image_meta import update_image_meta, dataset_id_to_meta
from nrtk_explorer.app.trame_utils import change_checker, delete_state
from nrtk_explorer.app.images.image_ids import (
dataset_id_to_image_id,
dataset_id_to_transformed_image_id,
Expand Down Expand Up @@ -86,6 +87,18 @@ def on_change_feature_enabled(self, **kwargs):
self.enabled_callback()


config_options = {
"models": {
"flags": ["--models"],
"params": {
"nargs": "+",
"default": INFERENCE_MODELS_DEFAULT,
"help": "Space separated list of inference models",
},
},
}


class TransformsApp(Applet):
def __init__(
self,
Expand All @@ -94,18 +107,12 @@ def __init__(
ground_truth_annotations=None,
original_detection_annotations=None,
transformed_detection_annotations=None,
**kwargs,
):
super().__init__(server)

self.server.cli.add_argument(
"--models",
nargs="+",
default=INFERENCE_MODELS_DEFAULT,
help="Space separated list of inference models",
)

known_args, _ = self.server.cli.parse_known_args()
self.state.inference_models = known_args.models
config = process_config(self.server.cli, config_options, **kwargs)
self.state.inference_models = config["models"]
self.state.inference_model = self.state.inference_models[0]
self.state.setdefault("image_list_ids", [])
self.state.setdefault("dataset_ids", [])
Expand Down
12 changes: 12 additions & 0 deletions src/nrtk_explorer/library/app_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def process_config(cli, config_options, **kwargs):
for opt in config_options.values():
cli.add_argument(*opt["flags"], **opt["params"])
known_args, _ = cli.parse_known_args()

config = {}
for name in config_options:
if name in kwargs:
config[name] = kwargs[name]
else:
config[name] = getattr(known_args, name)
return config
2 changes: 1 addition & 1 deletion src/nrtk_explorer/library/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def get_image(self, id: int):


def is_coco_dataset(path: str):
if not os.path.exists(path):
if not os.path.exists(path) or os.path.isdir(path):
return False
required_keys = ['"images"', '"categories"', '"annotations"']
with open(path) as f:
Expand Down

0 comments on commit 6e6ab8a

Please sign in to comment.