Use tqdm in JSONResolver, add a docstring

This commit is contained in:
Joel Holdbrooks 2023-01-23 12:11:42 -08:00
parent 1a0b7994f4
commit d9081e8198
1 changed files with 7 additions and 1 deletions

View File

@ -37,11 +37,17 @@ class DataResolver:
class JSONResolver(DataResolver):
def image_train_items(self, json_path: str) -> list[ImageTrainItem]:
"""
Create `ImageTrainItem` objects with metadata for hydration later.
Extracts images and captions from a JSON file.
:param json_path: The path to the JSON file.
"""
items = []
with open(json_path, encoding='utf-8', mode='r') as f:
json_data = json.load(f)
for data in json_data:
for data in tqdm.tqdm(json_data):
caption = JSONResolver.image_caption(data)
if caption:
image_value = JSONResolver.get_image_value(data)