<commit_before>#-*- coding: utf-8 -*-

import abc

class Descriptor(object):
    __metaclass__ = abc.ABCMeta
    
    def __init__(self):
        self._describe_behavior = None

    def describe(self):
        self._describe_behavior.operate()

class HOG(Descriptor):
    def __init__(self):
        self._describe_behavior = HOGDescriber()
    
class ColorHist(Descriptor):
    def __init__(self):
        self._describe_behavior = ColorHistDescriber()

class LBP(Descriptor):
    def __init__(self):
        self._describe_behavior = LBPDescriber()

class HuMoments(Descriptor):
    def __init__(self):
        self._describe_behavior = HuMomentsDescriber()


class Describer(object):
    def __init__(self):
        pass

    def operate(self):
        pass

class HOGDescriber(object):
    def __init__(self):
        pass

    def operate(self):
        pass

class ColorHistDescriber(object):
    def __init__(self):
        pass

    def operate(self):
        pass

class LBPDescriber(object):
    def __init__(self):
        pass

    def operate(self):
        pass

class HuMomentsDescriber(object):
    def __init__(self):
        pass

    def operate(self):
        pass<commit_msg>HOG class implementatio is done<commit_after>#-*- coding: utf-8 -*-

import abc
import numpy as np
from skimage import feature

class Descriptor(object):
    __metaclass__ = abc.ABCMeta
    
    def __init__(self):
        pass

    @abc.abstractmethod    
    def describe(self, images, **kwargs):
        """
        images 
            list of image
            
        kwargs
        """

        pass

class HOG(Descriptor):
    
    def describe(self, images, **kwargs):
        orientations = kwargs.pop('orientations', False)
        pixels_per_cell = kwargs.pop('pixels_per_cell', False)
        cells_per_block = kwargs.pop('cells_per_block', False)
        
        if kwargs:
            raise TypeError('Unexpected **kwargs: %r'.format(kwargs))
        
        features = []
        for image in images:
            feature_vector = feature.hog(image, 
                                   orientations=orientations, 
                                   pixels_per_cell=pixels_per_cell,
                                   cells_per_block=cells_per_block, 
                                   transform_sqrt=True)
            features.append(feature_vector)
            
        features = np.array(features)
        return features

class ColorHist(Descriptor):

    def describe(self):
        pass

class LBP(Descriptor):
    def __init__(self):
        pass

    def describe(self):
        pass

class HuMoments(Descriptor):
    def __init__(self):
        pass

    def describe(self):
        pass
    
if __name__ == "__main__":
    from skimage import data
    import cv2
    
    image = data.camera()        # Get Sample Image
    image = cv2.resize(image, (100, 100))

    hog = HOG()
    HH = hog.describe([image], orientations=9, pixels_per_cell=(8, 8), cells_per_block=(2, 2))
    # (4356L,), 0.0437659109109 0.0322149201473
    for H in HH:
        print H.shape, H[0], H[-1]








{'fraction_non_alphanumeric': 0.09468599033816426, 'fraction_numerical': 0.015780998389694042, 'mean_word_length': 2.072205736894164, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2463447', 'n_tokens_mistral': 977, 'n_tokens_neox': 899, 'n_words': 210}