# Path: third_party/data/base_dataset.py
# class BaseDataset(data.Dataset, ABC):
#     """This class is an abstract base class (ABC) for datasets.
# 
#     To create a subclass, you need to implement the following four functions:
#     -- <__init__>:                      initialize the class, first call BaseDataset.__init__(self, opt).
#     -- <__len__>:                       return the size of dataset.
#     -- <__getitem__>:                   get a data point.
#     -- <modify_commandline_options>:    (optionally) add dataset-specific options and set default options.
#     """
# 
#     def __init__(self, opt):
#         """Initialize the class; save the options in the class
# 
#         Parameters:
#             opt (Option class)-- stores all the experiment flags; needs to be a subclass of BaseOptions
#         """
#         self.opt = opt
#         self.root = opt.dataroot
# 
#     @staticmethod
#     def modify_commandline_options(parser, is_train):
#         """Add new dataset-specific options, and rewrite default values for existing options.
# 
#         Parameters:
#             parser          -- original option parser
#             is_train (bool) -- whether training phase or test phase. You can use this flag to add training-specific or test-specific options.
# 
#         Returns:
#             the modified parser.
#         """
#         return parser
# 
#     @abstractmethod
#     def __len__(self):
#         """Return the total number of images in the dataset."""
#         return 0
# 
#     @abstractmethod
#     def __getitem__(self, index):
#         """Return a data point and its metadata information.
# 
#         Parameters:
#             index - - a random integer for data indexing
# 
#         Returns:
#             a dictionary of data with their names. It ususally contains the data itself and its metadata information.
#         """
#         pass


from third_party.data.base_dataset import BaseDataset
from PIL import Image, ImageDraw
import json
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import os
import torchvision.transforms as transforms
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

matplotlib.use('Agg')


class KpuvDataset(BaseDataset):
    """A dataset class for keypoint data.

    It assumes that the directory specified by 'dataroot' contains the file 'keypoints.json'.
    """
    @staticmethod
    def modify_commandline_options(parser, is_train):
        parser.add_argument('--inp_size', type=int, default=256, help='image size')
        return parser

    def __init__(self, opt):
        """Initialize this dataset class by reading in keypoints.

        Parameters:
            opt (Option class) -- stores all the experiment flags; needs to be a subclass of BaseOptions
        """

# Path: third_party/data/base_dataset.py
# class BaseDataset(data.Dataset, ABC):
#     """This class is an abstract base class (ABC) for datasets.
# 
#     To create a subclass, you need to implement the following four functions:
#     -- <__init__>:                      initialize the class, first call BaseDataset.__init__(self, opt).
#     -- <__len__>:                       return the size of dataset.
#     -- <__getitem__>:                   get a data point.
#     -- <modify_commandline_options>:    (optionally) add dataset-specific options and set default options.
#     """
# 
#     def __init__(self, opt):
#         """Initialize the class; save the options in the class
# 
#         Parameters:
#             opt (Option class)-- stores all the experiment flags; needs to be a subclass of BaseOptions
#         """
#         self.opt = opt
#         self.root = opt.dataroot
# 
#     @staticmethod
#     def modify_commandline_options(parser, is_train):
#         """Add new dataset-specific options, and rewrite default values for existing options.
# 
#         Parameters:
#             parser          -- original option parser
#             is_train (bool) -- whether training phase or test phase. You can use this flag to add training-specific or test-specific options.
# 
#         Returns:
#             the modified parser.
#         """
#         return parser
# 
#     @abstractmethod
#     def __len__(self):
#         """Return the total number of images in the dataset."""
#         return 0
# 
#     @abstractmethod
#     def __getitem__(self, index):
#         """Return a data point and its metadata information.
# 
#         Parameters:
#             index - - a random integer for data indexing
# 
#         Returns:
#             a dictionary of data with their names. It ususally contains the data itself and its metadata information.
#         """
#         pass


# Path: data/kpuv_dataset.py
from third_party.data.base_dataset import BaseDataset
from PIL import Image, ImageDraw
import json
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import os
import torchvision.transforms as transforms

# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

matplotlib.use('Agg')


class KpuvDataset(BaseDataset):
    """A dataset class for keypoint data.

    It assumes that the directory specified by 'dataroot' contains the file 'keypoints.json'.
    """
    @staticmethod
    def modify_commandline_options(parser, is_train):
        parser.add_argument('--inp_size', type=int, default=256, help='image size')
        return parser

    def __init__(self, opt):
        """Initialize this dataset class by reading in keypoints.

        Parameters:
            opt (Option class) -- stores all the experiment flags; needs to be a subclass of BaseOptions
        """

        BaseDataset.__init__(self, opt)