當前位置: 首頁>>代碼示例>>Python>>正文


Python DB.getRevision方法代碼示例

本文整理匯總了Python中db.DB.getRevision方法的典型用法代碼示例。如果您正苦於以下問題:Python DB.getRevision方法的具體用法?Python DB.getRevision怎麽用?Python DB.getRevision使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在db.DB的用法示例。


在下文中一共展示了DB.getRevision方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: load

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import getRevision [as 別名]
    def load(self, best=False):
        print 'Model.load()'

        name   = '%s_%s'%(self.project.id, self.project.type)
        prefix = 'best' if best else 'latest'

        if self.offline:
            name = '%s_offline'%(name)
        elif best:
            revision = DB.getRevision( self.id )
            prefix   = '%s_%d'%(prefix, revision)

        # construct the path to the network and weights
        path = '%s/%s_%s'%(Paths.Models, prefix, name)
        j_path = '%s.json'%(path)
        w_path = '%s_weights.h5'%(path)

        j_path = j_path.lower()
        w_path = w_path.lower()
       
        if not os.path.exists( j_path ) or not os.path.exists( w_path ):
            return False

        print 'loading model...'
        self.model = model_from_json(open( j_path ).read())
        self.model.load_weights( w_path )
        return True
開發者ID:Rhoana,項目名稱:icon,代碼行數:29,代碼來源:model.py

示例2: get_path

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import getRevision [as 別名]
    def get_path(self):
        if self.offline:
            return self.path

        rev  = DB.getRevision( self.id )
        path = '%s/%s.%s.%d'%(Paths.Models, self.id, self.type, rev )
        return path.lower()
開發者ID:Rhoana,項目名稱:icon,代碼行數:9,代碼來源:oldunet2.py

示例3: save

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import getRevision [as 別名]
    def save(self, best=False):
        print 'Model.save()'

        if self.model == None:
            return False

        name   = '%s_%s'%(self.project.id, self.project.type)
        prefix = 'best' if best else 'latest'
       
        revision = 0
 
        if self.offline:
            name = '%s_offline'%(name)
        elif best:
            revision = DB.getRevision( self.id )
            revision = (revision+1)%10
            prefix   = '%s_%d'%(prefix, revision)

        # construct the path to the network and weights
        path = '%s/%s_%s'%(Paths.Models, prefix, name)
        j_path = '%s.json'%(path)
        w_path = '%s_weights.h5'%(path)

        j_path = j_path.lower()
        w_path = w_path.lower()

        print 'saving model...'
        json_string = self.model.to_json()
        open(j_path, 'w').write(json_string)
        self.model.save_weights(w_path, overwrite=True)

        if not self.offline:
            DB.finishSaveModel( self.project.id, revision )

        return True
開發者ID:Rhoana,項目名稱:icon,代碼行數:37,代碼來源:model.py

示例4: save_t

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import getRevision [as 別名]
 def save_t(self, version):
     revision = DB.getRevision( self.id )
     path = '%s/best_%s.%s.%d.%s.pkl'%(Paths.Models, self.id, self.type, revision, version)
     print 'saving - ', path
     with open(path, 'wb') as file:
         cPickle.dump((self.convLayers,
             self.mlp.hiddenLayers,
             self.mlp.logRegressionLayer,
             self.nkerns,
             self.kernelSizes,
             self.batchSize,
             self.patchSize,
             self.hiddenSizes),
             file)
開發者ID:Rhoana,項目名稱:icon,代碼行數:16,代碼來源:cnn.py

示例5: test_perf

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import getRevision [as 別名]
    def test_perf(self, project):
        name = 'train-input_0037.tif'
        path = '%s/%s'%(Paths.TrainGrayscale, name)
        image = mahotas.imread( path )
        image = Utility.normalizeImage( image )
        results = self.model.predict( image=image, mean=project.mean, std=project.std, threshold=project.threshold)
        n_membrane = len(results[ results == 1 ])
       
        print 'n_membrane:', n_membrane
 
        if n_membrane > 300000:
            rev  = DB.getRevision( self.model.id )
            version = '%d_%d'%(self.version, n_membrane)
            self.model.save_t( version )
            self.version += 1
開發者ID:thouis,項目名稱:icon,代碼行數:17,代碼來源:train.py

示例6: __init__

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import getRevision [as 別名]
    def __init__(
        self, 
        rng, 
        input, 
        n_in=None, 
        n_hidden=None, 
        n_out=2, 
        path=None, 
        id=None,
        offline=False,
        batch_size=None, 
        patch_size=None, 
        train_time=5.0,
        learning_rate=0.1,
        momentum=0.9,
        activation=rectified_linear):

        self.n_out = n_out
        self.n_in = n_in
        self.n_hidden = n_hidden
        self.input = input
        self.x = input

        self.id = id
        self.type = 'MLP'
        self.offline = offline
        self.rng = rng
        self.done = False
        self.path = path    
        self.activation = activation
        self.hiddenSizes = n_hidden
        self.batchSize = batch_size
        self.patchSize = patch_size 
        self.hiddenSizes = n_hidden
        self.learning_rate = learning_rate
        self.momentum      = momentum
        self.trainTime = train_time
        self.resample = False
        self.best_validation_loss = numpy.inf
        self.best_train_error = np.inf
	self.revision = DB.getRevision( self.id ) 
        self.initialize()
開發者ID:Rhoana,項目名稱:icon,代碼行數:44,代碼來源:mlp.py

示例7: get_paths

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import getRevision [as 別名]
    def get_paths(self, forSaving=False, forBest=False):
        name   = '%s_%s'%(self.project.id, self.project.type)
        prefix = 'best' if forBest else 'latest'
        posfix = ''

        revision = 0

        if not self.offline:
            revision = DB.getRevision( self.project.id )
            revision = (revision+1)%10
            posfix   = '_%d'%(revision) if forBest else ''
        else:
            name = '%s_offline'%(name)

        # construct the path to the network and weights
        path   = '%s/%s_%s%s'%(Paths.Models, prefix, name, posfix)
        j_path = '%s.json'%(path)
        w_path = '%s_weights.h5'%(path)

        return j_path.lower(), w_path.lower(), revision
開發者ID:Rhoana,項目名稱:icon,代碼行數:22,代碼來源:unet.py

示例8: save

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import getRevision [as 別名]
    def save(self):
        path = self.path

        revision = 0
        if not self.offline:
            revision = DB.getRevision( self.id )
            revision = (revision+1)%10
            path = '%s/best_%s.%s.%d.pkl'%(Paths.Models, self.id, self.type, revision)
            path = path.lower()

        print 'saving...', path
        with open(path, 'wb') as file:
            cPickle.dump((
                self.hiddenLayers, 
                self.logRegressionLayer, 
                self.n_in, 
                self.n_hidden), file)

        if not self.offline:
            DB.finishSaveModel( self.id, revision )
開發者ID:Rhoana,項目名稱:icon,代碼行數:22,代碼來源:mlp.py

示例9: save_best

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import getRevision [as 別名]
    def save_best(self):
        print 'Unet.save'
        path = Utility.get_dir(self.path)
        revision = 0
        if not self.offline:
            revision = DB.getRevision( self.id )
            revision = (revision+1)%10
            path = '%s/%s_%s_%d'%(Paths.Models, self.id, self.type, revision)
            path = path.lower()

        j_path = '%s_best.json'%(path)
        w_path = '%s_best_weights.h5'%(path)
        j_path = j_path.lower()
        w_path = w_path.lower()

        print 'saving...', path
        # saving code here...
        json_string = self.model.to_json()
        open(j_path, 'w').write(json_string)
        self.model.save_weights(w_path, overwrite=True)

        if not self.offline:
            DB.finishSaveModel( self.id, revision )
開發者ID:Rhoana,項目名稱:icon,代碼行數:25,代碼來源:oldunet2.py

示例10: work

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import getRevision [as 別名]
    def work(self, project):

        if not self.online:
            self.work_offline(project)
            self.done = True
            return

        start_time = time.clock()

        if project is None:
            return

        print 'prediction.... running', len(self.high)

        if len(self.high) == 0:
            self.high = DB.getPredictionImages( project.id, 1)


        #FG - march 4th 2016
        #if len(self.low) == 0:
        #    self.low = DB.getPredictionImages( project.id, 0 )

        '''
        for img in self.high:
            print 'hid:', img.id, img.modelModifiedTime, img.segmentationTime

        print '----'
        for img in self.low:
            print 'lid:', img.id, img.modelModifiedTime, img.segmentationTime

        exit(1)
        '''

        task = None
        if (self.priority == 0 or len(self.low) == 0) and len(self.high) > 0:
            self.priority = 1
            task = self.high[0]
            del self.high[0]
        elif len(self.low) > 0:
            self.priority = 0
            task = self.low[0]
            del self.low[0]

        if task == None:
            return

        has_new_model = (self.modTime != project.modelTime)
        revision = DB.getRevision( project.id )
        print 'revision:', revision
        #has_new_model = (revision != self.revision or has_new_model)

        # reload the model if it changed
        if has_new_model:
            #self.revision = revision
            print 'initializing...'
            self.model.initialize()
            self.modTime = project.modelTime

        # read image to segment
        basepath = Paths.TrainGrayscale if task.purpose == 0 else Paths.ValidGrayscale
        path = '%s/%s.tif'%(basepath, task.id)
        #success, image = Utility.get_image_padded(path, project.patchSize ) #model.get_patch_size())

        print 'segment - path:', path
        print 'priority - ', task.segmentationPriority
        # perform segmentation

        Utility.report_status('segmenting %s'%(task.id),'')
        #probs = self.model.predict( path )
        #probs = self.model.classify( image )

        # serialize to file
        segPath = '%s/%s.%s.seg'%(Paths.Segmentation, task.id, project.id)
        #self.save_probs( probs, project.id, task.id )
        self.classify_n_save( path, segPath, project )         

        end_time = time.clock()
        duration = (end_time - start_time)
        DB.finishPrediction( self.projectId, task.id, duration, self.modTime )
開發者ID:thouis,項目名稱:icon,代碼行數:81,代碼來源:segment.py


注:本文中的db.DB.getRevision方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。