From 12cf052889d49d1aacf215a4a920aa523a2eeb99 Mon Sep 17 00:00:00 2001 From: James Betker Date: Thu, 17 Dec 2020 10:16:21 -0700 Subject: [PATCH] Add an image patch labeling UI --- codes/data/image_folder_dataset.py | 2 +- codes/data/image_label_parser.py | 75 ++++---- .../ui/image_labeler/image_labeler_ui.py | 181 ++++++++++++++++++ .../pretrained_image_patch_classifier.py | 52 +++++ .../test_image_patch_classifier.py | 26 +++ 5 files changed, 303 insertions(+), 33 deletions(-) create mode 100644 codes/scripts/ui/image_labeler/image_labeler_ui.py create mode 100644 codes/scripts/ui/image_labeler/pretrained_image_patch_classifier.py create mode 100644 codes/scripts/ui/image_labeler/test_image_patch_classifier.py diff --git a/codes/data/image_folder_dataset.py b/codes/data/image_folder_dataset.py index 4279842d..9817cb62 100644 --- a/codes/data/image_folder_dataset.py +++ b/codes/data/image_folder_dataset.py @@ -134,7 +134,7 @@ if __name__ == '__main__': 'corrupt_before_downsize': True, 'labeler': { 'type': 'patch_labels', - 'label_file': 'F:\\4k6k\\datasets\\ns_images\\512_unsupervised\\categories.json' + 'label_file': 'F:\\4k6k\\datasets\\ns_images\\512_unsupervised\\categories_new.json' } } diff --git a/codes/data/image_label_parser.py b/codes/data/image_label_parser.py index f8d55c84..bc9a7a28 100644 --- a/codes/data/image_label_parser.py +++ b/codes/data/image_label_parser.py @@ -1,4 +1,5 @@ import os +from collections import OrderedDict import orjson as json # Given a JSON file produced by the VS.net image labeler utility, produces a dict where the keys are image file names @@ -9,39 +10,40 @@ import torch class VsNetImageLabeler: def __init__(self, label_file): - with open(label_file, "r") as read_file: - # Format of JSON file: - # "" { - # "label": "