Skip to content

Commit

Permalink
feat(init): add a no-metricize option (#152)
Browse files Browse the repository at this point in the history
* feat(init): add a no-metricize option

* fix(outliers): prevent int/float mismatches
  • Loading branch information
Encord-davids authored Feb 7, 2023
1 parent d215e88 commit 8f22c19
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
15 changes: 15 additions & 0 deletions src/encord_active/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
from encord_active.cli.utils.decorators import bypass_streamlit_question, ensure_project
from encord_active.cli.utils.prints import success_with_visualise_command
from encord_active.lib import constants as ea_constants
from encord_active.lib.metrics.execute import run_metrics, run_metrics_by_embedding_type
from encord_active.lib.metrics.heuristic.img_features import AreaMetric
from encord_active.lib.metrics.metric import EmbeddingType


class OrderedPanelGroup(TyperGroup):
Expand Down Expand Up @@ -147,6 +150,10 @@ def import_local_project(
False,
help="Print the files that will be imported WITHOUT importing them.",
),
metrics: bool = typer.Option(
True,
help="Run the metrics on the initiated project.",
),
):
"""
[green bold]Initialize[/green bold] a project from your local file system :seedling:
Expand Down Expand Up @@ -208,6 +215,14 @@ def import_local_project(
project_path = init_local_project(
files=glob_result.matched, target=target, project_name=project_name, symlinks=symlinks
)

metricize_options = {"data_dir": project_path, "use_cache_only": True}
if metrics:
run_metrics_by_embedding_type(EmbeddingType.IMAGE, **metricize_options)
else:
# NOTE: we need to compute at least one metric otherwise everything breaks
run_metrics(filter_func=lambda x: x.TITLE == AreaMetric.TITLE, **metricize_options)

success_with_visualise_command(project_path, "Project initialised :+1:")

except ProjectExistsError as e:
Expand Down
4 changes: 2 additions & 2 deletions src/encord_active/lib/dataset/outliers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@


class MetricWithDistanceSchema(MetricSchema):
dist_to_iqr: Optional[Series[float]] = pa.Field()
outliers_status: Optional[Series[str]] = pa.Field()
dist_to_iqr: Optional[Series[float]] = pa.Field(coerce=True)
outliers_status: Optional[Series[str]] = pa.Field(coerce=True)


class IqrOutliers(NamedTuple):
Expand Down
3 changes: 0 additions & 3 deletions src/encord_active/lib/project/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
LocalUserClient,
get_mimetype,
)
from encord_active.lib.metrics.execute import run_metrics_by_embedding_type
from encord_active.lib.metrics.metric import EmbeddingType

IMAGE_DATA_UNIT_FILENAME = "image_data_unit.json"

Expand Down Expand Up @@ -137,5 +135,4 @@ def init_local_project(

(project_dir / IMAGE_DATA_UNIT_FILENAME).write_text(json.dumps(image_to_du))

run_metrics_by_embedding_type(EmbeddingType.IMAGE, data_dir=client.project_path, use_cache_only=True)
return project_path

0 comments on commit 8f22c19

Please sign in to comment.