Skip to content

Commit

Permalink
fix: load faiss before torch, remove some module imports from the cri…
Browse files Browse the repository at this point in the history
…tical path (#180)

fix: load faiss before torch and move some module imports from the critical path
  • Loading branch information
Encord-davids authored Feb 15, 2023
1 parent 86f02de commit 2f05575
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/encord_active/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
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 @@ -162,6 +159,12 @@ def import_local_project(
By default, all jpeg, jpg, png, and tiff files will be matched.
"""
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
from encord_active.lib.project.local import (
NoFilesFoundError,
ProjectExistsError,
Expand Down
8 changes: 4 additions & 4 deletions src/encord_active/cli/print.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@

import rich
import typer
from encord.ontology import OntologyStructure
from rich.markup import escape

from encord_active.cli.config import app_config
from encord_active.cli.utils.decorators import ensure_project
from encord_active.lib.model_predictions.writer import (
iterate_classification_attribute_options,
)

print_cli = typer.Typer(rich_markup_mode="markdown")

Expand Down Expand Up @@ -48,8 +44,12 @@ def print_ontology(
"""
[bold]Prints[/bold] an ontology mapping between the class name to the `featureNodeHash` JSON format.
"""
from encord.ontology import OntologyStructure
from rich.panel import Panel

from encord_active.lib.model_predictions.writer import (
iterate_classification_attribute_options,
)
from encord_active.lib.project.project_file_structure import ProjectFileStructure

fs = ProjectFileStructure(target)
Expand Down
4 changes: 4 additions & 0 deletions src/encord_active/lib/metrics/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
from typing import Callable, List, Optional, Sequence, Tuple, Type, Union

import cv2

# NOTE: this statement enusres faiss is imported before torch.
# removing it will trigger segmentation faults in certain metrics
import faiss # pylint: disable=unused-import
from loguru import logger

from encord_active.lib.common.iterator import DatasetIterator, Iterator
Expand Down

0 comments on commit 2f05575

Please sign in to comment.