当前位置: 首页>>代码示例>>Python>>正文


Python FileIO.load方法代码示例

本文整理汇总了Python中FileIO.load方法的典型用法代码示例。如果您正苦于以下问题:Python FileIO.load方法的具体用法?Python FileIO.load怎么用?Python FileIO.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileIO的用法示例。


在下文中一共展示了FileIO.load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: saveCenters

# 需要导入模块: import FileIO [as 别名]
# 或者: from FileIO import load [as 别名]
def saveCenters(doOnlyFulls = False, trainingFolder = '../data/nicicon/csv/train/csv/' , suffix = '_train.csv', savePath = '../data/newMethodTraining/allCentersNic.csv'):
    """This file computes representatives of classes in the nicicon database and saves it to  the ./data/csv/allCentersNic.csv"""

    files = ['accident','bomb','car','casualty','electricity','fire','firebrigade','flood','gas','injury','paramedics', 'person', 'police','roadblock']
    centerSet  = []
    my_names = []
    my_isFull = []
    f = FileIO()


    extr_train = Extractor(trainingFolder)
    train_features, \
    train_isFull, \
    train_classId, \
    train_names = extr_train.loadniciconfolders()

    for mfile in files[:]:
        #Get every instance in the given class
        names, isFull, features = f.load(trainingFolder + mfile + '/' + mfile + suffix)

        #Initialise centers as 0
        nowCenter = np.zeros(len(features[0]))

        if not doOnlyFulls:
            #Use every full and partial instance in the class and sum them
            totalNumOfInstances = len(features)
            for instance in features:
                nowCenter += instance
        else:
            #Use only full instances in the class and sum them
            totalNumOfInstances = 0
            for i in range(len(features)):
                if isFull[i] == True:#Check the prints to see if this works fine (See if the totalNumOfInstances is meaningful
                    nowCenter+=features[i]
                    totalNumOfInstances+=1

        print mfile,'Used ', totalNumOfInstances, 'of instances to find the class center'

        nowCenter = nowCenter/totalNumOfInstances

        centerSet.append(nowCenter)#Add the mean feature vector for this representative
        my_names.append(mfile)#The name of the representative
        my_isFull.append(0)#Just set anything, not necessary for class representative
    f.save(my_isFull,my_names,centerSet,savePath)
开发者ID:ozymaxx,项目名称:sketchautocompletion,代码行数:46,代码来源:centersNic.py

示例2: saveCenters

# 需要导入模块: import FileIO [as 别名]
# 或者: from FileIO import load [as 别名]
def saveCenters(doOnlyFulls = True, getDataFrom = '../data/csv/', numClass =10 ** 6, savePath = '../data/newMethodTraining/allCenters.csv'):
    """This file computes centers of classes in the eitz database and saves it to savePath"""

    files = ['airplane', 'alarm-clock', 'angel', 'ant', 'apple', 'arm', 'armchair', 'ashtray', 'axe',
             'backpack', 'banana', 'barn', 'baseball-bat', 'basket', 'bathtub', 'bear-(animal)', 'bed',
             'bee', 'beer-mug', 'bell', 'bench', 'bicycle', 'binoculars', 'blimp', 'book', 'bookshelf',
             'boomerang', 'bottle-opener', 'bowl', 'brain', 'bread', 'bridge', 'bulldozer', 'bus', 'bush',
             'butterfly', 'cabinet', 'cactus', 'cake', 'calculator', 'camel', 'camera', 'candle', 'cannon',
             'canoe', 'car-(sedan)', 'carrot', 'castle', 'cat', 'cell-phone', 'chair', 'chandelier',
             'church', 'cigarette', 'cloud', 'comb', 'computer-monitor', 'computer-mouse', 'couch', 'cow',
             'crab', 'crane-(machine)', 'crocodile', 'crown', 'cup', 'diamond', 'dog', 'dolphin', 'donut',
             'door', 'door-handle', 'dragon', 'duck', 'ear', 'elephant', 'envelope', 'eye', 'eyeglasses',
             'face', 'fan', 'feather', 'fire-hydrant', 'fish', 'flashlight', 'floor-lamp', 'flower-with-stem',
             'flying-bird', 'flying-saucer', 'foot', 'fork', 'frog', 'frying-pan', 'giraffe', 'grapes',
             'grenade', 'guitar', 'hamburger', 'hammer', 'hand', 'harp', 'hat', 'head', 'head-phones',
             'hedgehog', 'helicopter', 'helmet', 'horse', 'hot-air-balloon', 'hot-dog', 'hourglass',
             'house', 'human-skeleton', 'ice-cream-cone', 'ipod', 'kangaroo', 'key', 'keyboard', 'knife',
             'ladder', 'laptop', 'leaf', 'lightbulb', 'lighter', 'lion', 'lobster', 'loudspeaker',
             'mailbox', 'megaphone', 'mermaid', 'microphone', 'microscope', 'monkey', 'moon', 'mosquito',
             'motorbike', 'mouse-(animal)', 'mouth', 'mug', 'mushroom', 'nose', 'octopus', 'owl',
             'palm-tree', 'panda', 'paper-clip', 'parachute', 'parking-meter', 'parrot', 'pear', 'pen',
             'penguin', 'person-sitting', 'person-walking', 'piano', 'pickup-truck', 'pig', 'pigeon',
             'pineapple', 'pipe-(for-smoking)', 'pizza', 'potted-plant', 'power-outlet', 'present',
             'pretzel', 'pumpkin', 'purse', 'rabbit', 'race-car', 'radio', 'rainbow', 'revolver',
             'rifle', 'rollerblades', 'rooster', 'sailboat', 'santa-claus', 'satellite', 'satellite-dish',
             'saxophone', 'scissors', 'scorpion', 'screwdriver', 'sea-turtle', 'seagull', 'shark',
             'sheep', 'ship', 'shoe', 'shovel', 'skateboard', 'skull', 'skyscraper', 'snail', 'snake',
             'snowboard', 'snowman', 'socks', 'space-shuttle', 'speed-boat', 'spider', 'sponge-bob',
             'spoon', 'squirrel', 'standing-bird', 'stapler', 'strawberry', 'streetlight', 'submarine',
             'suitcase', 'sun', 'suv', 'swan', 'sword', 'syringe', 't-shirt', 'table', 'tablelamp',
             'teacup', 'teapot', 'teddy-bear', 'telephone', 'tennis-racket', 'tent', 'tiger', 'tire',
             'toilet', 'tomato', 'tooth', 'toothbrush', 'tractor', 'traffic-light', 'train', 'tree',
             'trombone', 'trousers', 'truck', 'trumpet', 'tv', 'umbrella', 'van', 'vase', 'violin',
             'walkie-talkie', 'wheel', 'wheelbarrow', 'windmill', 'wine-bottle', 'wineglass', 'wrist-watch',
             'zebra']

    centerSet  = []
    my_names = []
    my_isFull = []
    f = FileIO()

    #Set number of classes to find centers
    if(numClass == None):
        numClass = len(files)
    else:
        numClass = min(numClass, len(files))


    for mfile in files[:numClass]:

        #Get every instance in the given class
        names, isFull, features = f.load(getDataFrom + mfile + '/' + mfile + '.csv')

        #Initialise centers as 0
        nowCenter = np.zeros(len(features[0]))


        if not doOnlyFulls:
            #Use every full and partial instance in the class and sum them
            totalNumOfInstances = len(features)
            for instance in features:
                nowCenter += instance
        else:
            #Use only full instances in the class and sum them
            totalNumOfInstances = 0
            for i in range(len(features)):
                if isFull[i] == True:#Check the prints to see if this works fine (See if the totalNumOfInstances is meaningful
                    nowCenter+=features[i]
                    totalNumOfInstances+=1

        print mfile,'Used ', totalNumOfInstances, 'of instances to find the class center'

        nowCenter = nowCenter/totalNumOfInstances

        centerSet.append(nowCenter)#Add the mean feature vector for this representative
        my_names.append(mfile)#The name of the representative
        my_isFull.append(0)#Just set anything, not necessary for class representative
    f.save(my_isFull,my_names,centerSet,savePath)
开发者ID:ozymaxx,项目名称:sketchautocompletion,代码行数:80,代码来源:centersEitz.py

示例3: listdir

# 需要导入模块: import FileIO [as 别名]
# 或者: from FileIO import load [as 别名]
                for f in listdir(symbolspat) if not isfile(join(symbolspat, f))]

# concatenate all inner lists
imagefolders = [x for y in imagefolders for x in y]
imagefolders.sort()
fio = FileIO()
missingNames = []
for folder in imagefolders:
    # get the images
    imgpaths = [join(folder, f) for f in listdir(folder) if isfile(join(folder, f))]
    imgpaths.sort()
    imagenames = [imgpath[imgpath.rfind('/')+1:-4] for imgpath in imgpaths]

    folderspl = folder.split('/')
    className = folderspl[-3]
    type = folderspl[-2] # train, eval or test

    csvname =className + '_' + type + '.csv'#car-train.csv
    names, isFull, features = fio.load('C:/Users/1003/Desktop/nicicon/csv/' + type + '/' + className + '/' + csvname)
    missingNames.extend([folder  + imgname + '.xml' for imgname in imagenames if imgname not in names])

    import os
print missingNames


    #pathtowrite = 'C:/Users/1003/Desktop/nicicon/csv/' + className + '/'
    #fio.save(isFull, names, features, 'C:/Users/1003/Desktop/nicicon/csv/' + type + '/' + className + '/' + csvname)



开发者ID:ozymaxx,项目名称:sketchautocompletion,代码行数:29,代码来源:finddefecientxml.py


注:本文中的FileIO.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。