Skip to content

Commit afe5ceb

Browse files
authored
print exports dirs after process finishes (#318)
* remove redundant logger lines * print export dir for predict, coco evaluate, coco error analyse commands * print export dirs after process finishes
1 parent f83e9f8 commit afe5ceb

6 files changed

+14
-11
lines changed

sahi/model.py

-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
from sahi.utils.torch import cuda_is_available, empty_cuda_cache
1212

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

2015

2116
class DetectionModel:

sahi/predict.py

+3
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,9 @@ def predict(
544544
save_path = str(save_dir / "result.json")
545545
save_json(coco_json, save_path)
546546

547+
if export_visual or export_pickle or export_crop or dataset_json_path is not None:
548+
print(f"Prediction results are sucessfully exported to {save_dir}")
549+
547550
# print prediction duration
548551
if verbose == 2:
549552
print(

sahi/scripts/coco2yolov5.py

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def main(
3838
numpy_seed=seed,
3939
)
4040

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

4244
if __name__ == "__main__":
4345
fire.Fire(main)

sahi/scripts/coco_error_analysis.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def _analyze_results(
261261
), "3 integers should be specified as areas, \
262262
representing 3 area regions"
263263

264-
if not out_dir:
264+
if out_dir is None:
265265
out_dir = Path(res_file).parent
266266
out_dir = str(out_dir / "coco_error_analysis")
267267

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

333334

334335
def main(
335336
dataset_json_path: str,
336337
result_json_path: str,
337-
out_dir: str,
338+
out_dir: str = None,
338339
type: str = "bbox",
339340
extraplots: bool = False,
340341
areas: List[int] = [1024, 9216, 10000000000],

sahi/scripts/coco_evaluation.py

+1
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ def evaluate_coco(
343343
# export as json
344344
with open(save_path, "w", encoding="utf-8") as outfile:
345345
json.dump(eval_results, outfile, indent=4, separators=(",", ":"))
346+
print(f"COCO evaluation results are successfully exported to {save_path}")
346347
return eval_results
347348

348349

sahi/scripts/slice_coco.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def main(
1414
ignore_negative_samples: bool = False,
1515
project: str = "runs/slice_coco",
1616
name: str = "exp",
17+
min_area_ratio: float = 0.1,
1718
):
1819
"""
1920
Args:
@@ -24,6 +25,9 @@ def main(
2425
ignore_negative_samples (bool): ignore images without annotation
2526
project (str): save results to project/name
2627
name (str): save results to project/name
28+
min_area_ratio (float): If the cropped annotation area to original
29+
annotation ratio is smaller than this value, the annotation
30+
is filtered out. Default 0.1.
2731
"""
2832

2933
# assure slice_size is list
@@ -56,10 +60,7 @@ def main(
5660
)
5761
output_coco_annotation_file_path = os.path.join(output_dir, sliced_coco_name + ".json")
5862
save_json(coco_dict, output_coco_annotation_file_path)
59-
print(
60-
f"Sliced 'slice_size: {slice_size}' coco file is saved to",
61-
output_coco_annotation_file_path,
62-
)
63+
print(f"Sliced dataset for 'slice_size: {slice_size}' is exported to {output_dir}")
6364

6465

6566
if __name__ == "__main__":

0 commit comments

Comments
 (0)