Esempio n. 1
0
    def __init__(self, name, inputSlot=None, processFunc=None,
                 outputType=None, slotType=None, iterator=None, sequence=None, classes=None,
                 useLazyEvaluation=pynopticon.useLazyEvaluation, useCaching=pynopticon.useCaching):

        self.name = name
        self.inputSlot = inputSlot
        self.outputType = outputType
        self.iterator = iterator
        self.sequence = sequence
        self.processFunc = processFunc

        # Create an output container
        if self.sequence is not None:
            self.container = SeqContainer(sequence=self.sequence, classes=classes, useLazyEvaluation=useLazyEvaluation, useCaching=useCaching)
        elif self.iterator is not None: # User defined iterator
            self.container = SeqContainer(generator=self.iterator, classes=classes, useLazyEvaluation=useLazyEvaluation, useCaching=useCaching)
        elif slotType == 'sequential': # Sequential iterator
            if self.processFunc is None and self.processFuncs is None:
                raise AttributeError, "You must provide processFunc or processFuncs to use generic iterators"
            self.container = SeqContainer(generator=pynopticon.weakmethod(self, 'seqIterator'), classes=classes, useLazyEvaluation=useLazyEvaluation, useCaching=useCaching)
        elif slotType == 'bulk': # Bulk iterator
            if self.processFunc is None and self.processFuncs is None:
                raise AttributeError, "You must provide processFunc or processFuncs to use generic iterators"
            self.container = SeqContainer(generator=pynopticon.weakmethod(self, 'bulkIterator'), classes=classes, useLazyEvaluation=useLazyEvaluation, useCaching=useCaching)
        else:
            self.container = None
Esempio n. 2
0
    def __init__(self, **kwargs):
        super(VectorType, self).__init__(**kwargs)

        self.attributes = {'shape': ['nestedlist', 'nestedarray', 'flatarray', 'flatlist'],
                           'length': [type(1)]
                           }

        self.conversions = [{'shape': ('nestedlist', 'flatarray'),
                             'function': pynopticon.weakmethod(self, 'convert_nestedlist_to_flatarray')},
                            {'shape': ('nestedarray', 'flatarray'),
                             'function': pynopticon.weakmethod(self, 'convert_nestedlist_to_flatarray')}
                            ]
Esempio n. 3
0
    def __init__(self,
                 name,
                 inputSlot=None,
                 processFunc=None,
                 outputType=None,
                 slotType=None,
                 iterator=None,
                 sequence=None,
                 classes=None,
                 useLazyEvaluation=pynopticon.useLazyEvaluation,
                 useCaching=pynopticon.useCaching):

        self.name = name
        self.inputSlot = inputSlot
        self.outputType = outputType
        self.iterator = iterator
        self.sequence = sequence
        self.processFunc = processFunc

        # Create an output container
        if self.sequence is not None:
            self.container = SeqContainer(sequence=self.sequence,
                                          classes=classes,
                                          useLazyEvaluation=useLazyEvaluation,
                                          useCaching=useCaching)
        elif self.iterator is not None:  # User defined iterator
            self.container = SeqContainer(generator=self.iterator,
                                          classes=classes,
                                          useLazyEvaluation=useLazyEvaluation,
                                          useCaching=useCaching)
        elif slotType == 'sequential':  # Sequential iterator
            if self.processFunc is None and self.processFuncs is None:
                raise AttributeError, "You must provide processFunc or processFuncs to use generic iterators"
            self.container = SeqContainer(generator=pynopticon.weakmethod(
                self, 'seqIterator'),
                                          classes=classes,
                                          useLazyEvaluation=useLazyEvaluation,
                                          useCaching=useCaching)
        elif slotType == 'bulk':  # Bulk iterator
            if self.processFunc is None and self.processFuncs is None:
                raise AttributeError, "You must provide processFunc or processFuncs to use generic iterators"
            self.container = SeqContainer(generator=pynopticon.weakmethod(
                self, 'bulkIterator'),
                                          classes=classes,
                                          useLazyEvaluation=useLazyEvaluation,
                                          useCaching=useCaching)
        else:
            self.container = None
Esempio n. 4
0
    def __init__(self):
        # For every slot we can define the type of data that is
        # exepected or outputted, for more info have a look at
        # slots.py

        # Input is expected to be images in PIL format
        inputType = pnc.slots.ImageType(format=["PIL"], color_space=["gray"])
        # Output is a flat array (a 2D array consisting of vectors)
        outputType = pnc.slots.VectorType(name='Example', shape='flatarray')

        # Next we have to define an input and an output slot which
        # will handle the data sending and receiving
        self.inputSlot = pnc.slots.InputSlot(name='Images',
                                             acceptsType=inputType)

        # We have several options of defining an output slot (see the
        # help for slots.OutputSlots for more infos).  Here, we create
        # an output slot that receives data from our just defined
        # inputSlot and calls the function self.process() on every
        # element.  The reason we are using pnc.weakmethod(class,
        # method) instead of handing self.process directly is purely
        # technical.
        self.outputSlot = pnc.slots.OutputSlot(name='Example',
                                               inputSlot=self.inputSlot,
                                               processFunc=pnc.weakmethod(
                                                   self, 'process'),
                                               outputType=outputType)
Esempio n. 5
0
    def __init__(self):
        # For every slot we can define the type of data that is
        # exepected or outputted, for more info have a look at
        # slots.py

        # Input is expected to be images in PIL format
        inputType = pnc.slots.ImageType(format=["PIL"], color_space=["gray"])
        # Output is a flat array (a 2D array consisting of vectors)
    	outputType = pnc.slots.VectorType(name='Example', shape='flatarray')

        # Next we have to define an input and an output slot which
        # will handle the data sending and receiving
        self.inputSlot = pnc.slots.InputSlot(name='Images',
                                             acceptsType = inputType)

	    # We have several options of defining an output slot (see the
        # help for slots.OutputSlots for more infos).  Here, we create
        # an output slot that receives data from our just defined
        # inputSlot and calls the function self.process() on every
        # element.  The reason we are using pnc.weakmethod(class,
        # method) instead of handing self.process directly is purely
        # technical.
    	self.outputSlot = pnc.slots.OutputSlot(name='Example',
                                               inputSlot = self.inputSlot,
                                               processFunc = pnc.weakmethod(self, 'process'),
                                               outputType = outputType)
Esempio n. 6
0
    def __init__(self,
                 scoretype='clustering',
                 useLazyEvaluation=pynopticon.useLazyEvaluation):
        self.scoretype = scoretype
        if self.scoretype not in ['clustering']:
            raise NotImplementedError, "No such score type"

        self.inputTypeData = pynopticon.slots.VectorType(shape=['flatarray'],
                                                         bulk=True)
        self.inputTypeLabels = pynopticon.slots.VectorType(name=['labels'],
                                                           shape=['flatlist'])

        self.outputType = pynopticon.slots.VectorType(shape='flatarray')

        self.inputSlotData = pynopticon.slots.InputSlot(
            name='untransformed', acceptsType=self.inputTypeData)

        self.inputSlotLabels = pynopticon.slots.InputSlot(
            name='labels', acceptsType=self.inputTypeLabels)

        self.outputSlot = pynopticon.slots.OutputSlot(
            name='transformed',
            outputType=self.outputType,
            useLazyEvaluation=useLazyEvaluation,
            iterator=pynopticon.weakmethod(self, 'iterator'))
Esempio n. 7
0
    def __init__(self, transtype, kernel=None, useLazyEvaluation=pynopticon.useLazyEvaluation):
        self.transtype = transtype
        if self.transtype not in ['PCA','KPCA', 'LLE', 'none']:
            raise NotImplementedError, "No operation mode specified"

        if kernel is None:
            self.kernel = 'gaussian_kernel'
        elif kernel not in ['linear_kernel', 'gaussian_kernel', 'chi2_kernel']:
            raise NotImplementedError, "Wrong kernel chosen"
        else:
            self.kernel = kernel
        

        self.inputTypeData = pynopticon.slots.VectorType(shape=['flatarray'], bulk=True)
        self.inputTypeLabels = pynopticon.slots.VectorType(name=['labels'], shape=['flatlist'])
        
        self.outputType = pynopticon.slots.VectorType(shape='flatarray')

        self.inputSlotData = pynopticon.slots.InputSlot(name='untransformed',
                                                   acceptsType=self.inputTypeData)

        self.inputSlotLabels = pynopticon.slots.InputSlot(name='labels',
                                                     acceptsType=self.inputTypeLabels)

        self.outputSlot = pynopticon.slots.OutputSlot(name='transformed',
                                                 outputType=self.outputType,
                                                 useLazyEvaluation=useLazyEvaluation,
                                                 iterator=pynopticon.weakmethod(self, 'iterator'))
Esempio n. 8
0
    def __init__(self, filter=None, useLazyEvaluation=pynopticon.useLazyEvaluation):

	self.filters = {'blur': ImageFilter.BLUR,
			'contour': ImageFilter.CONTOUR,
			'detail': ImageFilter.DETAIL,
			'edge_enhance': ImageFilter.EDGE_ENHANCE,
			'edge_enhance_more': ImageFilter.EDGE_ENHANCE_MORE,
			'emboss': ImageFilter.EMBOSS,
			'find_edges': ImageFilter.FIND_EDGES,
			'sharpen': ImageFilter.SHARPEN,
			'smooth': ImageFilter.SMOOTH,
			'smooth_more': ImageFilter.SMOOTH_MORE,
                        'none': None}
			   
        self.useLazyEvaluation = useLazyEvaluation

	# Define types
	inputType = pynopticon.slots.ImageType(format=["PIL"])

	# Define slots
	self.inputSlot = pynopticon.slots.InputSlot(name='Images', acceptsType = inputType, useLazyEvaluation=useLazyEvaluation)
	self.outputSlot = pynopticon.slots.OutputSlot(name='Filtered Images',
                                                 inputSlot=self.inputSlot,
                                                 processFunc=pynopticon.weakmethod(self, 'applyfilter'),
                                                 slotType='sequential',
                                                 useLazyEvaluation=self.useLazyEvaluation)
	self.filter = filter
Esempio n. 9
0
    def __init__(self,
                 filter=None,
                 useLazyEvaluation=pynopticon.useLazyEvaluation):

        self.filters = {
            'blur': ImageFilter.BLUR,
            'contour': ImageFilter.CONTOUR,
            'detail': ImageFilter.DETAIL,
            'edge_enhance': ImageFilter.EDGE_ENHANCE,
            'edge_enhance_more': ImageFilter.EDGE_ENHANCE_MORE,
            'emboss': ImageFilter.EMBOSS,
            'find_edges': ImageFilter.FIND_EDGES,
            'sharpen': ImageFilter.SHARPEN,
            'smooth': ImageFilter.SMOOTH,
            'smooth_more': ImageFilter.SMOOTH_MORE,
            'none': None
        }

        self.useLazyEvaluation = useLazyEvaluation

        # Define types
        inputType = pynopticon.slots.ImageType(format=["PIL"])

        # Define slots
        self.inputSlot = pynopticon.slots.InputSlot(
            name='Images',
            acceptsType=inputType,
            useLazyEvaluation=useLazyEvaluation)
        self.outputSlot = pynopticon.slots.OutputSlot(
            name='Filtered Images',
            inputSlot=self.inputSlot,
            processFunc=pynopticon.weakmethod(self, 'applyfilter'),
            slotType='sequential',
            useLazyEvaluation=self.useLazyEvaluation)
        self.filter = filter
Esempio n. 10
0
    def __init__(self,
                 transtype,
                 kernel=None,
                 useLazyEvaluation=pynopticon.useLazyEvaluation):
        self.transtype = transtype
        if self.transtype not in ['PCA', 'KPCA', 'LLE', 'none']:
            raise NotImplementedError, "No operation mode specified"

        if kernel is None:
            self.kernel = 'gaussian_kernel'
        elif kernel not in ['linear_kernel', 'gaussian_kernel', 'chi2_kernel']:
            raise NotImplementedError, "Wrong kernel chosen"
        else:
            self.kernel = kernel

        self.inputTypeData = pynopticon.slots.VectorType(shape=['flatarray'],
                                                         bulk=True)
        self.inputTypeLabels = pynopticon.slots.VectorType(name=['labels'],
                                                           shape=['flatlist'])

        self.outputType = pynopticon.slots.VectorType(shape='flatarray')

        self.inputSlotData = pynopticon.slots.InputSlot(
            name='untransformed', acceptsType=self.inputTypeData)

        self.inputSlotLabels = pynopticon.slots.InputSlot(
            name='labels', acceptsType=self.inputTypeLabels)

        self.outputSlot = pynopticon.slots.OutputSlot(
            name='transformed',
            outputType=self.outputType,
            useLazyEvaluation=useLazyEvaluation,
            iterator=pynopticon.weakmethod(self, 'iterator'))
Esempio n. 11
0
    def __init__(self, **kwargs):
        super(ImageType, self).__init__(**kwargs)
        
        self.attributes = {'format': ['PIL', 'numpy'],
                          'color_space': ['gray', 'RGB']
                           }

        self.conversions = [{'format': ('PIL', 'PIL'),
                             'color_space': ('RGB', 'gray'),
                             'function': pynopticon.weakmethod(self, 'convert_PIL_RGB_to_PIL_gray')},
                            {'format': ('PIL', 'numpy'),
                             'color_space': ('RGB', 'RGB'),
                             'function': pynopticon.weakmethod(self, 'convert_PIL_RGB_to_numpy_RGB')},
                            {'format': ('PIL', 'numpy'),
                             'color_space': ('RGB', 'gray'),
                             'function': pynopticon.weakmethod(self, 'convert_PIL_RGB_to_numpy_gray')}
                            ]
Esempio n. 12
0
    def __init__(self, **kwargs):
        super(VectorType, self).__init__(**kwargs)

        self.attributes = {
            'shape': ['nestedlist', 'nestedarray', 'flatarray', 'flatlist'],
            'length': [type(1)]
        }

        self.conversions = [{
            'shape': ('nestedlist', 'flatarray'),
            'function':
            pynopticon.weakmethod(self, 'convert_nestedlist_to_flatarray')
        }, {
            'shape': ('nestedarray', 'flatarray'),
            'function':
            pynopticon.weakmethod(self, 'convert_nestedlist_to_flatarray')
        }]
Esempio n. 13
0
    def registerInput(self, senderSlot):
        """Register senderSlot as an inputSlot. inputType and
        outputType have to match (or be convertable).
        """
        if pynopticon.useTypeChecking and self.acceptsType is not None:
            if senderSlot.outputType is not None:
                senderType = senderSlot.outputType
            elif senderSlot.inputSlot.outputType is not None:
                # If the output slot does not transform the input
                # type, it may be found in the inputslot
                senderType = senderSlot.inputSlot.outputType
            else:
                raise ValueError, "No types specified"
            # Check if sender type is compatible with us or if we can
            # convert (compatible() will return converter functions)
            compatible = self.acceptsType.compatible(senderType)
            if compatible == False:
                raise TypeError, "Slots are not compatible"
            # Else compatible() returns the new type and conversion funcs
            (self.outputType, self.converters) = compatible

        # Register the new slot
        self.senderSlot = weakref.ref(senderSlot)

        # Callback to tell the senderSlot container to update its data
        # (if necessary)
        # senderSlot.container.recompute()

        if pynopticon.useCaching:
            # Register us to the senderSlot
            senderSlot.container.registerReference(self)

        # Initialize the container to store the data (or the reference to it)
        if not self.bulk:
            self.container = SeqContainer(
                generator=pynopticon.weakmethod(self, 'convertSequential'),
                useLazyEvaluation=self.useLazyEvaluation)
        else:
            self.container = SeqContainer(
                generator=pynopticon.weakmethod(self, 'convertBulk'),
                useLazyEvaluation=self.useLazyEvaluation)
Esempio n. 14
0
    def __init__(self, useLazyEvaluation=pynopticon.useLazyEvaluation):
        self.inputType = pynopticon.slots.ImageType(format=['PIL'], color_space=['gray'])
        self.outputType = pynopticon.slots.VectorType(shape='flatarray')

        self.inputSlot = pynopticon.slots.InputSlot(name='unnormalized',
                                               acceptsType=self.inputType)

        self.outputSlot = pynopticon.slots.OutputSlot(name='normalized',
                                                 inputSlot=self.inputSlot,
                                                 slotType='sequential',
                                                 processFunc=pynopticon.weakmethod(self, 'fft2'),
                                                 outputType=self.outputType,
                                                 useLazyEvaluation=useLazyEvaluation)
Esempio n. 15
0
    def __init__(self, useLazyEvaluation=pynopticon.useLazyEvaluation):
        self.useLazyEvaluation = useLazyEvaluation
        
        self.inputType = pynopticon.slots.VectorType(shape=['flatarray'])
        self.outputType = pynopticon.slots.VectorType(shape='flatarray')
        self.inputSlots = []

        self.inputSlot = property(fget=self.__createSlot)
        
        self.outputSlot = pynopticon.slots.OutputSlot(name='concatenated',
                                                 iterator=pynopticon.weakmethod(self, 'concatenate'),
						 outputType=self.outputType,
                                                 useLazyEvaluation = self.useLazyEvaluation)
Esempio n. 16
0
    def registerInput(self, senderSlot):
        """Register senderSlot as an inputSlot. inputType and
        outputType have to match (or be convertable).
        """
        if pynopticon.useTypeChecking and self.acceptsType is not None:
            if senderSlot.outputType is not None:
                senderType = senderSlot.outputType
            elif senderSlot.inputSlot.outputType is not None:
                # If the output slot does not transform the input
                # type, it may be found in the inputslot
                senderType = senderSlot.inputSlot.outputType
            else:
                raise ValueError, "No types specified"
            # Check if sender type is compatible with us or if we can
            # convert (compatible() will return converter functions)
            compatible = self.acceptsType.compatible(senderType)
            if compatible == False:
                raise TypeError, "Slots are not compatible"
            # Else compatible() returns the new type and conversion funcs
            (self.outputType, self.converters) = compatible
            

        # Register the new slot
        self.senderSlot = weakref.ref(senderSlot)
    
        # Callback to tell the senderSlot container to update its data
        # (if necessary)
        # senderSlot.container.recompute()

        if pynopticon.useCaching:
            # Register us to the senderSlot
            senderSlot.container.registerReference(self)

        # Initialize the container to store the data (or the reference to it)
        if not self.bulk:
            self.container = SeqContainer(generator=pynopticon.weakmethod(self, 'convertSequential'), useLazyEvaluation=self.useLazyEvaluation)
        else:
            self.container = SeqContainer(generator=pynopticon.weakmethod(self, 'convertBulk'), useLazyEvaluation=self.useLazyEvaluation)
Esempio n. 17
0
    def __init__(self, **kwargs):
        super(ImageType, self).__init__(**kwargs)

        self.attributes = {
            'format': ['PIL', 'numpy'],
            'color_space': ['gray', 'RGB']
        }

        self.conversions = [{
            'format': ('PIL', 'PIL'),
            'color_space': ('RGB', 'gray'),
            'function':
            pynopticon.weakmethod(self, 'convert_PIL_RGB_to_PIL_gray')
        }, {
            'format': ('PIL', 'numpy'),
            'color_space': ('RGB', 'RGB'),
            'function':
            pynopticon.weakmethod(self, 'convert_PIL_RGB_to_numpy_RGB')
        }, {
            'format': ('PIL', 'numpy'),
            'color_space': ('RGB', 'gray'),
            'function':
            pynopticon.weakmethod(self, 'convert_PIL_RGB_to_numpy_gray')
        }]
Esempio n. 18
0
    def __init__(self, useLazyEvaluation=pynopticon.useLazyEvaluation):
        self.inputType = pynopticon.slots.ImageType(format=['PIL'],
                                                    color_space=['gray'])
        self.outputType = pynopticon.slots.VectorType(shape='flatarray')

        self.inputSlot = pynopticon.slots.InputSlot(name='unnormalized',
                                                    acceptsType=self.inputType)

        self.outputSlot = pynopticon.slots.OutputSlot(
            name='normalized',
            inputSlot=self.inputSlot,
            slotType='sequential',
            processFunc=pynopticon.weakmethod(self, 'fft2'),
            outputType=self.outputType,
            useLazyEvaluation=useLazyEvaluation)
Esempio n. 19
0
    def __init__(self, bins, useLazyEvaluation=pynopticon.useLazyEvaluation):
        self.useLazyEvaluation = useLazyEvaluation
        self.bins = bins
        
        inputType = pynopticon.slots.VectorType(shape=['flatarray'])
        outputType = pynopticon.slots.VectorType(shape='flatarray')

        self.inputSlot = pynopticon.slots.InputSlot(name='vector',
                                               acceptsType=inputType)

        self.outputSlot = pynopticon.slots.OutputSlot(name='histogram',
                                                 inputSlot = self.inputSlot,
                                                 slotType = 'sequential',
                                                 processFunc = pynopticon.weakmethod(self, 'histogram'),
						 outputType = outputType,
                                                 useLazyEvaluation = self.useLazyEvaluation)
Esempio n. 20
0
    def __init__(self, useLazyEvaluation=pynopticon.useLazyEvaluation, **kwargs):
        self.useLazyEvaluation = useLazyEvaluation
        self.kwargs = kwargs

        # Define types
        self.inputType = pynopticon.slots.ImageType(format=["PIL"])
        self.outputType = pynopticon.slots.VectorType(shape='nestedarray')

        # Define slots
        self.inputSlot = pynopticon.slots.InputSlot(name='Images', acceptsType = self.inputType, useLazyEvaluation=useLazyEvaluation)
        self.outputSlot = pynopticon.slots.OutputSlot(name='Sift Descriptors',
                                                outputType=self.outputType,
                                                inputSlot=self.inputSlot,
                                                processFunc=pynopticon.weakmethod(self, 'process'),
                                                slotType='sequential',
                                                useLazyEvaluation=self.useLazyEvaluation)
Esempio n. 21
0
    def __init__(self, useLazyEvaluation=pynopticon.useLazyEvaluation):
        self.inputTypeData = pynopticon.slots.VectorType(shape=['flatarray'])
        self.inputTypeLabels = pynopticon.slots.VectorType(name=['labels'], shape=['flatlist'])
        
        self.outputType = pynopticon.slots.VectorType(shape='flatarray')

        self.inputSlotData = pynopticon.slots.InputSlot(name='untransformed',
                                                   acceptsType=self.inputTypeData)

        self.inputSlotLabels = pynopticon.slots.InputSlot(name='labels',
                                                     acceptsType=self.inputTypeLabels)

        self.outputSlot = pynopticon.slots.OutputSlot(name='transformed',
                                                 outputType=self.outputType,
                                                 useLazyEvaluation=useLazyEvaluation,
                                                 iterator=pynopticon.weakmethod(self, 'iterator'))
Esempio n. 22
0
    def __init__(self, normtype, useLazyEvaluation=pynopticon.useLazyEvaluation):
        self.normtype = normtype
        #if self.normtype in ['bin', 'L1','L2', 'whiten', 'bias', 'crop', 'log', 'none']:
        #    raise ValueError, "No operation mode specified"

        self.inputType = pynopticon.slots.VectorType(shape=['flatarray'], bulk=True)

        self.outputType = pynopticon.slots.VectorType(shape='flatarray')

        self.inputSlot = pynopticon.slots.InputSlot(name='unnormalized',
                                               acceptsType=self.inputType)

        self.outputSlot = pynopticon.slots.OutputSlot(name='normalized',
                                                 inputSlot=self.inputSlot,
                                                 slotType='bulk',
                                                 processFunc=pynopticon.weakmethod(self, 'normalize'),
                                                 outputType=self.outputType,
                                                 useLazyEvaluation=useLazyEvaluation)
Esempio n. 23
0
    def __init__(self, useLazyEvaluation=pynopticon.useLazyEvaluation):
        self.inputTypeData = pynopticon.slots.VectorType(shape=['flatarray'])
        self.inputTypeLabels = pynopticon.slots.VectorType(name=['labels'],
                                                           shape=['flatlist'])

        self.outputType = pynopticon.slots.VectorType(shape='flatarray')

        self.inputSlotData = pynopticon.slots.InputSlot(
            name='untransformed', acceptsType=self.inputTypeData)

        self.inputSlotLabels = pynopticon.slots.InputSlot(
            name='labels', acceptsType=self.inputTypeLabels)

        self.outputSlot = pynopticon.slots.OutputSlot(
            name='transformed',
            outputType=self.outputType,
            useLazyEvaluation=useLazyEvaluation,
            iterator=pynopticon.weakmethod(self, 'iterator'))
Esempio n. 24
0
    def __init__(self, metric = 'euclidean', plot=True, useLazyEvaluation=pynopticon.useLazyEvaluation):

        self.metric = metric
        self.plot = plot
        
        self.inputTypeData = pynopticon.slots.VectorType(shape=['flatarray'])
        self.outputType = pynopticon.slots.VectorType(shape='flatarray')

        self.inputSlot = pynopticon.slots.InputSlot(name='data',
                                               acceptsType=self.inputTypeData,
                                               bulk=True)


        self.outputSlot = pynopticon.slots.OutputSlot(name='distance matrix',
                                                 outputType=self.outputType,
                                                 useLazyEvaluation=useLazyEvaluation,
                                                 slotType = 'bulk',
                                                 inputSlot=self.inputSlot,
                                                 processFunc = pynopticon.weakmethod(self, 'pdist'))
Esempio n. 25
0
    def __init__(self, useLazyEvaluation=pynopticon.useLazyEvaluation):

        self.useLazyEvaluation = useLazyEvaluation

        # Define types
        inputTypeVec = pynopticon.slots.VectorType(shape=['nestedlist', 'nestedarray'])
        inputTypeCodebook = pynopticon.slots.VectorType(name=['codebook'], shape=['flatarray'])
        
        outputType = pynopticon.slots.VectorType(shape='flatarray')

        # Define slots
        self.inputSlotVec = pynopticon.slots.InputSlot(name='vectors',
                                                  acceptsType=inputTypeVec)

        self.inputSlotCodebook = pynopticon.slots.InputSlot(name='codebook',
                                                       acceptsType=inputTypeCodebook)
        
        self.outputSlot = pynopticon.slots.OutputSlot(name='cluster',
                                                 outputType=outputType,
                                                 iterator=pynopticon.weakmethod(self, 'quantize'),
                                                 useLazyEvaluation=self.useLazyEvaluation)
Esempio n. 26
0
    def __init__(self,
                 metric='euclidean',
                 plot=True,
                 useLazyEvaluation=pynopticon.useLazyEvaluation):

        self.metric = metric
        self.plot = plot

        self.inputTypeData = pynopticon.slots.VectorType(shape=['flatarray'])
        self.outputType = pynopticon.slots.VectorType(shape='flatarray')

        self.inputSlot = pynopticon.slots.InputSlot(
            name='data', acceptsType=self.inputTypeData, bulk=True)

        self.outputSlot = pynopticon.slots.OutputSlot(
            name='distance matrix',
            outputType=self.outputType,
            useLazyEvaluation=useLazyEvaluation,
            slotType='bulk',
            inputSlot=self.inputSlot,
            processFunc=pynopticon.weakmethod(self, 'pdist'))
Esempio n. 27
0
    def __init__(self, scoretype='clustering', useLazyEvaluation=pynopticon.useLazyEvaluation):
        self.scoretype = scoretype
        if self.scoretype not in ['clustering']:
            raise NotImplementedError, "No such score type"


        self.inputTypeData = pynopticon.slots.VectorType(shape=['flatarray'], bulk=True)
        self.inputTypeLabels = pynopticon.slots.VectorType(name=['labels'], shape=['flatlist'])
        
        self.outputType = pynopticon.slots.VectorType(shape='flatarray')

        self.inputSlotData = pynopticon.slots.InputSlot(name='untransformed',
                                                  acceptsType=self.inputTypeData)

        self.inputSlotLabels = pynopticon.slots.InputSlot(name='labels',
                                                    acceptsType=self.inputTypeLabels)

        self.outputSlot = pynopticon.slots.OutputSlot(name='transformed',
                                                outputType=self.outputType,
                                                useLazyEvaluation=useLazyEvaluation,
                                                iterator=pynopticon.weakmethod(self, 'iterator'))
Esempio n. 28
0
    def __init__(self, featureType, useLazyEvaluation=pynopticon.useLazyEvaluation, **kwargs):
        if featureType in Nowozin.features:
            self.featureType = featureType
        else:
            raise NotImplementedError, "Feature Type %s not implemented" % featureType
        
        self.kwargs = kwargs
        self.useLazyEvaluation = useLazyEvaluation
        
        
        # Define types
        self.inputType = pynopticon.slots.ImageType(format=["PIL"])
        self.outputType = pynopticon.slots.VectorType(shape='nestedarray')

        # Define slots
        self.inputSlot = pynopticon.slots.InputSlot(name='Images', acceptsType = self.inputType, useLazyEvaluation=useLazyEvaluation)
        self.outputSlot = pynopticon.slots.OutputSlot(name='Sift Descriptors',
                                                outputType=self.outputType,
                                                inputSlot=self.inputSlot,
                                                processFunc=pynopticon.weakmethod(self, 'process'),
                                                slotType='sequential',
                                                useLazyEvaluation=self.useLazyEvaluation)
Esempio n. 29
0
    def __init__(self,
                 normtype,
                 useLazyEvaluation=pynopticon.useLazyEvaluation):
        self.normtype = normtype
        #if self.normtype in ['bin', 'L1','L2', 'whiten', 'bias', 'crop', 'log', 'none']:
        #    raise ValueError, "No operation mode specified"

        self.inputType = pynopticon.slots.VectorType(shape=['flatarray'],
                                                     bulk=True)

        self.outputType = pynopticon.slots.VectorType(shape='flatarray')

        self.inputSlot = pynopticon.slots.InputSlot(name='unnormalized',
                                                    acceptsType=self.inputType)

        self.outputSlot = pynopticon.slots.OutputSlot(
            name='normalized',
            inputSlot=self.inputSlot,
            slotType='bulk',
            processFunc=pynopticon.weakmethod(self, 'normalize'),
            outputType=self.outputType,
            useLazyEvaluation=useLazyEvaluation)
Esempio n. 30
0
    def __init__(self, numClusters, maxiter=0, numruns=20, sampleFromData=1., useLazyEvaluation=pynopticon.useLazyEvaluation):
        """ numClusters: Number of clusters centroids
            maxiter: How many iterations to run maximally
            numruns: How often to start the algorithm
            sampleFromData: How much of the input data to use -- often it is not necessary to use all the data
            """
        self.numClusters = numClusters
        self.maxiter = maxiter
        self.numruns = numruns
        self.sampleFromData = sampleFromData
	self.useLazyEvaluation = useLazyEvaluation
	
	# Define some types
	inputType = pynopticon.slots.VectorType(shape=['flatarray'])
	outputType = pynopticon.slots.VectorType(name='codebook', shape='flatarray')

	self.inputSlot = pynopticon.slots.InputSlot(name='vectors', acceptsType = inputType, bulk=True, useLazyEvaluation=useLazyEvaluation)
	
	self.outputSlot = pynopticon.slots.OutputSlot(name='codebook',
						inputSlot = self.inputSlot,
						slotType = 'bulk',
						processFunc = pynopticon.weakmethod(self, 'process'),
						outputType = outputType,
						useLazyEvaluation= self.useLazyEvaluation)
Esempio n. 31
0
 def __init__(self, useLazyEvaluation=pynopticon.useLazyEvaluation):
     self.inputSlot = pynopticon.slots.MultiInputSlot(name='data')
     self.outputSlot = pynopticon.slots.OutputSlot(
         name='combined data',
         iterator=pynopticon.weakmethod(self, 'iterator'),
         useLazyEvaluation=useLazyEvaluation)
 def setUp(self):
     self.seqContainer = SeqContainer(generator=pynopticon.weakmethod(self, 'iterator'), useLazyEvaluation=True)
Esempio n. 33
0
 def __init__(self, useLazyEvaluation=pynopticon.useLazyEvaluation):
     self.inputSlot = pynopticon.slots.MultiInputSlot(name='data')
     self.outputSlot = pynopticon.slots.OutputSlot(name='combined data',
                                              iterator=pynopticon.weakmethod(self, 'iterator'),
                                              useLazyEvaluation=useLazyEvaluation)
Esempio n. 34
0
 def setUp(self):
     self.seqContainer = SeqContainer(generator=pynopticon.weakmethod(
         self, 'iterator'),
                                      useLazyEvaluation=True)