Created
August 26, 2016 16:31
-
-
Save YaronBlinder/6bd95297d93649530b10e55db15820b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from .calculateSC import * | |
from cv2 import imread | |
import pandas as pd | |
from wolong.base import BasePlugin | |
from wolong.cli import entrypoint | |
class CalcSCPlugin(BasePlugin): # REQUIRED | |
consumes_cols = ['filenames'] # REQUIRED | |
provides_cols = ['SpatialCorrelation'] # REQUIRED | |
def __init__(self, df): | |
super(CalcSCPlugin, self).__init__(df) # REQUIRED | |
def process(self, window_size): # TYPICAL | |
def _helper(filenames): | |
SC = calculateSC(filenames,spatial_correlation=True,window_size=window_size) | |
return {'SpatialCorrelation': SC} | |
new_df = self._df.apply(_helper) # Do some computation | |
self.result = new_df # REQUIRED | |
class CalcTCPlugin(BasePlugin): # REQUIRED | |
consumes_cols = ['filenames'] # REQUIRED | |
provides_cols = ['TemporalCorrelation'] # REQUIRED | |
def __init__(self, df): | |
super(CalcCPlugin, self).__init__(df) # REQUIRED | |
def process(self, window_size): # TYPICAL | |
def _helper(filenames): | |
SC = calculateSC(filenames,temporal_correlation=True,window_size=window_size) | |
return {'TemporalCorrelation': SC} | |
new_df = self._df.apply(_helper) # Do some computation | |
self.result = new_df # REQUIRED | |
class CalcRenderPlugin(BasePlugin): # REQUIRED | |
consumes_cols = ['filename'] # REQUIRED | |
provides_cols = ['new_filenames'] # REQUIRED | |
def __init__(self, df): | |
super(CalcRenderPlugin, self).__init__(df) # REQUIRED | |
def process(self): # TYPICAL | |
# def _helper(filename_s): | |
# input_arr = imread(filename_s) | |
# output_arr = calculateSC(input_image) | |
# with tempfile.mktemp(suffix=".bmp") as tfile: | |
# imwrite(output_arr, tfile) | |
# return {'new_filename': output_img} | |
# new_df = self._df.apply(_helper) # Do some computation | |
# self.result = new_df # REQUIRED | |
pass | |
def setargs(parser): # TYPICAL | |
parser.add_argument('-w', '--window-size', default=5, type=int) | |
@entrypoint(['algo', 'calc', 'SC'], args=setargs) #REQUIRED | |
def cli_run_my_plgin(api, ns, parser): # REQUIRED | |
plugin = CalcSCPlugin(api.cursor) # TYPICAL | |
plugin.process() # TYPICAL | |
api.cursor = plugin.result # TYPICAL | |
@entrypoint(['algo', 'calc', 'TC'], args=setargs) #REQUIRED | |
def cli_run_my_plgin(api, ns, parser): # REQUIRED | |
plugin = CalcTCPlugin(api.cursor) # TYPICAL | |
plugin.process(...) # TYPICAL | |
api.cursor = plugin.result # TYPICAL | |
@entrypoint(['algo', 'calc', 'Render'], args=setargs) #REQUIRED | |
def cli_run_my_plgin(api, ns, parser): # REQUIRED | |
plugin = CalcRenderPlugin(api.cursor) # TYPICAL | |
plugin.process(...) # TYPICAL | |
api.cursor = plugin.result # TYPICAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment