From d9081e8198ad17a341105016e78f54cc540b6fd4 Mon Sep 17 00:00:00 2001 From: Joel Holdbrooks Date: Mon, 23 Jan 2023 12:11:42 -0800 Subject: [PATCH] Use tqdm in JSONResolver, add a docstring --- data/resolver.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/data/resolver.py b/data/resolver.py index 185a0fb..973c0b2 100644 --- a/data/resolver.py +++ b/data/resolver.py @@ -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)