Spaces:
Runtime error
Runtime error
Commit
·
e96f741
1
Parent(s):
b78886d
fixed cache
Browse files
data.py
CHANGED
|
@@ -236,18 +236,18 @@ def generate_annotated_images():
|
|
| 236 |
yield AnnotatedImage.from_image_id(image_id)
|
| 237 |
|
| 238 |
|
| 239 |
-
@functools.
|
| 240 |
def load_train_image_ids() -> list[str]:
|
| 241 |
train_image_ids = [i.replace(".jpg", "") for i in os.listdir("data/train/images")]
|
| 242 |
return train_image_ids[: 1000 if CONFIG.debug else None]
|
| 243 |
|
| 244 |
|
| 245 |
-
@functools.
|
| 246 |
def load_test_image_ids() -> list[str]:
|
| 247 |
return [i.replace(".jpg", "") for i in os.listdir("data/test/images")]
|
| 248 |
|
| 249 |
|
| 250 |
-
@functools.
|
| 251 |
def load_image_annotation(image_id: str) -> dict:
|
| 252 |
return json.load(open(f"data/train/annotations/{image_id}.json"))
|
| 253 |
|
|
@@ -309,7 +309,7 @@ def to_token_str(value: str or enum.Enum):
|
|
| 309 |
return f"<{string}>"
|
| 310 |
|
| 311 |
|
| 312 |
-
@functools.
|
| 313 |
def get_extra_tokens() -> types.SimpleNamespace:
|
| 314 |
token_ns = types.SimpleNamespace()
|
| 315 |
|
|
|
|
| 236 |
yield AnnotatedImage.from_image_id(image_id)
|
| 237 |
|
| 238 |
|
| 239 |
+
@functools.lru_cache
|
| 240 |
def load_train_image_ids() -> list[str]:
|
| 241 |
train_image_ids = [i.replace(".jpg", "") for i in os.listdir("data/train/images")]
|
| 242 |
return train_image_ids[: 1000 if CONFIG.debug else None]
|
| 243 |
|
| 244 |
|
| 245 |
+
@functools.lru_cache
|
| 246 |
def load_test_image_ids() -> list[str]:
|
| 247 |
return [i.replace(".jpg", "") for i in os.listdir("data/test/images")]
|
| 248 |
|
| 249 |
|
| 250 |
+
@functools.lru_cache
|
| 251 |
def load_image_annotation(image_id: str) -> dict:
|
| 252 |
return json.load(open(f"data/train/annotations/{image_id}.json"))
|
| 253 |
|
|
|
|
| 309 |
return f"<{string}>"
|
| 310 |
|
| 311 |
|
| 312 |
+
@functools.lru_cache
|
| 313 |
def get_extra_tokens() -> types.SimpleNamespace:
|
| 314 |
token_ns = types.SimpleNamespace()
|
| 315 |
|