Skip to content

Commit

Permalink
print exports dirs after process finishes (#318)
Browse files Browse the repository at this point in the history
* remove redundant logger lines

* print export dir for predict, coco evaluate, coco error analyse commands

* print export dirs after process finishes
  • Loading branch information
fcakyon committed Dec 26, 2021
1 parent f83e9f8 commit afe5ceb
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
5 changes: 0 additions & 5 deletions sahi/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
from sahi.utils.torch import cuda_is_available, empty_cuda_cache

logger = logging.getLogger(__name__)
logging.basicConfig(
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
datefmt="%m/%d/%Y %H:%M:%S",
level=os.environ.get("LOGLEVEL", "INFO").upper(),
)


class DetectionModel:
Expand Down
3 changes: 3 additions & 0 deletions sahi/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,9 @@ def predict(
save_path = str(save_dir / "result.json")
save_json(coco_json, save_path)

if export_visual or export_pickle or export_crop or dataset_json_path is not None:
print(f"Prediction results are sucessfully exported to {save_dir}")

# print prediction duration
if verbose == 2:
print(
Expand Down
2 changes: 2 additions & 0 deletions sahi/scripts/coco2yolov5.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def main(
numpy_seed=seed,
)

print(f"COCO to YOLOv5 conversion results are sucessfully exported to {save_dir}")


if __name__ == "__main__":
fire.Fire(main)
5 changes: 3 additions & 2 deletions sahi/scripts/coco_error_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def _analyze_results(
), "3 integers should be specified as areas, \
representing 3 area regions"

if not out_dir:
if out_dir is None:
out_dir = Path(res_file).parent
out_dir = str(out_dir / "coco_error_analysis")

Expand Down Expand Up @@ -329,12 +329,13 @@ def _analyze_results(
_makebarplot(recThrs, ps, res_out_dir, "allclass", iou_type)
_make_gt_area_group_numbers_plot(cocoEval=cocoEval, outDir=res_out_dir, verbose=True)
_make_gt_area_histogram_plot(cocoEval=cocoEval, outDir=res_out_dir)
print(f"COCO error analysis results are successfully exported to {out_dir}")


def main(
dataset_json_path: str,
result_json_path: str,
out_dir: str,
out_dir: str = None,
type: str = "bbox",
extraplots: bool = False,
areas: List[int] = [1024, 9216, 10000000000],
Expand Down
1 change: 1 addition & 0 deletions sahi/scripts/coco_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ def evaluate_coco(
# export as json
with open(save_path, "w", encoding="utf-8") as outfile:
json.dump(eval_results, outfile, indent=4, separators=(",", ":"))
print(f"COCO evaluation results are successfully exported to {save_path}")
return eval_results


Expand Down
9 changes: 5 additions & 4 deletions sahi/scripts/slice_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def main(
ignore_negative_samples: bool = False,
project: str = "runs/slice_coco",
name: str = "exp",
min_area_ratio: float = 0.1,
):
"""
Args:
Expand All @@ -24,6 +25,9 @@ def main(
ignore_negative_samples (bool): ignore images without annotation
project (str): save results to project/name
name (str): save results to project/name
min_area_ratio (float): If the cropped annotation area to original
annotation ratio is smaller than this value, the annotation
is filtered out. Default 0.1.
"""

# assure slice_size is list
Expand Down Expand Up @@ -56,10 +60,7 @@ def main(
)
output_coco_annotation_file_path = os.path.join(output_dir, sliced_coco_name + ".json")
save_json(coco_dict, output_coco_annotation_file_path)
print(
f"Sliced 'slice_size: {slice_size}' coco file is saved to",
output_coco_annotation_file_path,
)
print(f"Sliced dataset for 'slice_size: {slice_size}' is exported to {output_dir}")


if __name__ == "__main__":
Expand Down

0 comments on commit afe5ceb

Please sign in to comment.