Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Verbose and make Citation Reminder only appeare once #98

Merged
merged 3 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions panoptica/panoptic_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def evaluate(
decision_threshold=self.__decision_threshold,
result_all=result_all,
log_times=self.__log_times,
verbose=self.__verbose if verbose is None else verbose,
verbose=True if verbose is None else verbose,
verbose_calc=self.__verbose if verbose is None else verbose,
)


Expand All @@ -98,7 +99,8 @@ def panoptic_evaluate(
edge_case_handler: EdgeCaseHandler | None = None,
log_times: bool = False,
result_all: bool = True,
verbose: bool = False,
verbose=False,
verbose_calc=False,
**kwargs,
) -> tuple[PanopticaResult, dict[str, _ProcessingPair]]:
"""
Expand Down Expand Up @@ -128,14 +130,16 @@ def panoptic_evaluate(
>>> panoptic_evaluate(SemanticPair(...), instance_approximator=InstanceApproximator(), iou_threshold=0.6)
(PanopticaResult(...), {'UnmatchedInstanceMap': _ProcessingPair(...), 'MatchedInstanceMap': _ProcessingPair(...)})
"""
print("Panoptic: Start Evaluation")
if verbose:
print("Panoptic: Start Evaluation")
if edge_case_handler is None:
# use default edgecase handler
edge_case_handler = EdgeCaseHandler()
debug_data: dict[str, _ProcessingPair] = {}
# First Phase: Instance Approximation
if isinstance(processing_pair, PanopticaResult):
print("-- Input was Panoptic Result, will just return")
if verbose:
print("-- Input was Panoptic Result, will just return")
return processing_pair, debug_data

# Crops away unecessary space of zeroes
Expand All @@ -145,7 +149,8 @@ def panoptic_evaluate(
assert (
instance_approximator is not None
), "Got SemanticPair but not InstanceApproximator"
print("-- Got SemanticPair, will approximate instances")
if verbose:
print("-- Got SemanticPair, will approximate instances")
processing_pair = instance_approximator.approximate_instances(processing_pair)
start = perf_counter()
processing_pair = instance_approximator.approximate_instances(processing_pair)
Expand All @@ -162,7 +167,8 @@ def panoptic_evaluate(
)

if isinstance(processing_pair, UnmatchedInstancePair):
print("-- Got UnmatchedInstancePair, will match instances")
if verbose:
print("-- Got UnmatchedInstancePair, will match instances")
assert (
instance_matcher is not None
), "Got UnmatchedInstancePair but not InstanceMatchingAlgorithm"
Expand All @@ -184,7 +190,8 @@ def panoptic_evaluate(
)

if isinstance(processing_pair, MatchedInstancePair):
print("-- Got MatchedInstancePair, will evaluate instances")
if verbose:
print("-- Got MatchedInstancePair, will evaluate instances")
processing_pair = evaluate_matched_instance(
processing_pair,
eval_metrics=eval_metrics,
Expand All @@ -197,7 +204,7 @@ def panoptic_evaluate(

if isinstance(processing_pair, PanopticaResult):
if result_all:
processing_pair.calculate_all(print_errors=verbose)
processing_pair.calculate_all(print_errors=verbose_calc)
return processing_pair, debug_data

raise RuntimeError("End of panoptic pipeline reached without results")
Expand Down
3 changes: 2 additions & 1 deletion panoptica/timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ def wrapper(*args, **kwargs):
result = func(*args, **kwargs)
end_time = time.time()
elapsed_time = end_time - start_time
print(f"-- {func.__name__} took {elapsed_time} seconds to execute.")
if hasattr(kwargs, "verbose") and getattr(kwargs, "verbose"):
print(f"-- {func.__name__} took {elapsed_time} seconds to execute.")
return result

return wrapper
3 changes: 2 additions & 1 deletion panoptica/utils/citation_reminder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def wrapper(*args, **kwargs):
console = Console()
console.rule("Thank you for using [bold]panoptica[/bold]")
console.print(
f"Please support our development by citing",
"Please support our development by citing",
justify="center",
)
console.print(
Expand All @@ -22,6 +22,7 @@ def wrapper(*args, **kwargs):
)
console.rule()
console.line()
os.environ["PANOPTICA_CITATION_REMINDER"] = "false" # Show only once
return func(*args, **kwargs)

return wrapper
Loading