# Path: deeppy/dataset/util.py
# def touch(filepath, times=None):
# def require_dir(path):
# def url_filename(url):
# def download(url, target_dir, filename=None):
# def checkpoint(filepath):
# def is_archive(filepath):
# def archive_extract(filepath, target_dir):
# def checksum(filename, method='sha1'):
# def _read_int(buf):
# def load_idx(filepath):


import os
import shutil
import logging
import numpy as np
import scipy.io
from PIL import Image
from .util import dataset_home, download, checksum, archive_extract, checkpoint
                i = 0
                for line in f:
                    i += 1
                    fields = [s.strip() for s in line.split('\t')]
                    person_id = fields[0].replace(' ', '_')
                    img_no = int(fields[1].replace(' ', '_'))
                    attr_vec = np.array([float(s) for s in fields[2:]])
                    if person_id not in attributes:
                        attributes[person_id] = {}
                    attributes[person_id][img_no] = attr_vec

            with open(self._attributes_path, 'wb') as f:
                np.savez(f, attributes=attributes,
                         attribute_names=attribute_names)

    def _load_attributes(self):
        self._install_attributes()
        with open(self._attributes_path, 'rb') as f:
            dic = np.load(f)
            self._attributes = dic['attributes'][()]
            self._attribute_names = dic['attribute_names'][()]

    def _install_landmarks(self):
        checkpoint_file = os.path.join(self.data_dir, '__landm_install_check')
        with checkpoint(checkpoint_file) as exists:
            if exists:
                return
            url, md5 = _LANDMARKS_URL
            filepath = self._download(url, md5)
            log.info('Unpacking %s', filepath)

# Path: deeppy/dataset/util.py
# def touch(filepath, times=None):
# def require_dir(path):
# def url_filename(url):
# def download(url, target_dir, filename=None):
# def checkpoint(filepath):
# def is_archive(filepath):
# def archive_extract(filepath, target_dir):
# def checksum(filename, method='sha1'):
# def _read_int(buf):
# def load_idx(filepath):


# Path: deeppy/dataset/lfw.py
import os
import shutil
import logging
import numpy as np
import scipy.io
from PIL import Image
from .util import dataset_home, download, checksum, archive_extract, checkpoint

                i = 0
                for line in f:
                    i += 1
                    fields = [s.strip() for s in line.split('\t')]
                    person_id = fields[0].replace(' ', '_')
                    img_no = int(fields[1].replace(' ', '_'))
                    attr_vec = np.array([float(s) for s in fields[2:]])
                    if person_id not in attributes:
                        attributes[person_id] = {}
                    attributes[person_id][img_no] = attr_vec

            with open(self._attributes_path, 'wb') as f:
                np.savez(f, attributes=attributes,
                         attribute_names=attribute_names)

    def _load_attributes(self):
        self._install_attributes()
        with open(self._attributes_path, 'rb') as f:
            dic = np.load(f)
            self._attributes = dic['attributes'][()]
            self._attribute_names = dic['attribute_names'][()]

    def _install_landmarks(self):
        checkpoint_file = os.path.join(self.data_dir, '__landm_install_check')
        with checkpoint(checkpoint_file) as exists:
            if exists:
                return
            url, md5 = _LANDMARKS_URL
            filepath = self._download(url, md5)
            log.info('Unpacking %s', filepath)

            archive_extract(filepath, self.data_dir)