From 2ccf8676d9d9633369c9ab8ac0e391cff3055b07 Mon Sep 17 00:00:00 2001 From: Prithviraj Banerjee Date: Tue, 27 Aug 2024 17:34:06 -0700 Subject: [PATCH] add the SAM2_COMPUTE_SCORE step to flow job Summary: add the SAM2_COMPUTE_SCORE step to flow job Reviewed By: SeaOtocinclus Differential Revision: D61341812 fbshipit-source-id: b8ccfe38d5e9ff2bd5068843b18468dbf6422221 --- hot3d/data_loaders/io_utils.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hot3d/data_loaders/io_utils.py b/hot3d/data_loaders/io_utils.py index 049ec39..301e262 100644 --- a/hot3d/data_loaders/io_utils.py +++ b/hot3d/data_loaders/io_utils.py @@ -41,8 +41,30 @@ def is_float(x: Any) -> bool: return False +def is_int(x: Any) -> bool: + """ + Function checks if the input is convertible to int + """ + if x is None: + return False + if len(x) == 0: + return False + try: + int(x) + return True + except ValueError: + return False + + def float_or_none(x: Any) -> Optional[float]: """ Function returns a float if x is convertible to float, otherwise None """ return float(x) if is_float(x) else None + + +def int_or_none(x: Any) -> Optional[int]: + """ + Function returns a int if x is convertible to int, otherwise None + """ + return int(x) if is_int(x) else None