Spaces:
Sleeping
Sleeping
Upload env.py
Browse files
env.py
CHANGED
|
@@ -45,6 +45,9 @@ def calculate_iou(box1: List[List[int]], box2: List[List[int]]) -> float:
|
|
| 45 |
class MetaOCTEnv:
|
| 46 |
def __init__(self, data_dir: str = "images", truth_file: str = "ground_truth.json", difficulty: str = "medium"):
|
| 47 |
self.data_dir = data_dir
|
|
|
|
|
|
|
|
|
|
| 48 |
with open(truth_file, "r") as f:
|
| 49 |
self.ground_truth = json.load(f)
|
| 50 |
self.image_files = list(self.ground_truth.keys())
|
|
|
|
| 45 |
class MetaOCTEnv:
|
| 46 |
def __init__(self, data_dir: str = "images", truth_file: str = "ground_truth.json", difficulty: str = "medium"):
|
| 47 |
self.data_dir = data_dir
|
| 48 |
+
# Support both flat root upload (HuggingFace) and local images/ folder
|
| 49 |
+
if not os.path.isdir(data_dir):
|
| 50 |
+
self.data_dir = "." # Fallback to root directory
|
| 51 |
with open(truth_file, "r") as f:
|
| 52 |
self.ground_truth = json.load(f)
|
| 53 |
self.image_files = list(self.ground_truth.keys())
|