Пример #1
0
def Load_Aligned_Data():
    '''Function that read already downloaded files.
    Returns a mmdatasdk class with speech and text
    multimodal data features'''

    dataset_set = {"glove_vectors.csd", "COVAREP.csd", "Sentiment Labels.csd"}
    dataset_dictionary = {}
    BASE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    path = os.path.join(BASE_PATH, 'dataloaders/mosei_aligned')

    if os.path.isdir(path) is False:
        print("Folder does not exist ...")
        exit(-1)

    csdfiles = [
        f for f in listdir(path)
        if isfile(join(path, f)) and f[-4:] == '.csd' and (f in dataset_set)
    ]
    if len(csdfiles) == 0:
        print("No csd files in the given folder")
        exit(-2)

    print("%d csd files found" % len(csdfiles))
    for csdfile in csdfiles:
        dataset_dictionary[csdfile] = os.path.join(path, csdfile)
    dataset = mmdatasdk.mmdataset(dataset_dictionary)

    print("List of the computational sequences")
    print(dataset.computational_sequences.keys())

    return (dataset)
Пример #2
0
def ReadDlData(name_dict, path):
    '''Function that read already downloaded files
    from specified given path which is given as
    input argument. Returns a mmdatasdk class with
    all available multimodal data features'''

    url_dictionary = InverseMap(name_dict)
    dataset_dictionary={}

    if os.path.isdir(path) is False:
        print ("Folder does not exist ...")
        exit(-1)

    csdfiles = [f for f in listdir(path) if isfile(join(path, f)) and f[-4:]=='.csd']
    if len(csdfiles)==0:
        print("No csd files in the given folder")
        exit(-2)

    highlevel_names = SearchDictKeys(url_dictionary, csdfiles)

    print("%d csd files found"%len(csdfiles))
    for csdfile in csdfiles:
        dataset_dictionary[highlevel_names[csdfile]]=os.path.join(path,csdfile)
    dataset=mmdatasdk.mmdataset(dataset_dictionary)

    print ("List of the computational sequences")
    print (dataset.computational_sequences.keys())

    return(dataset)
Пример #3
0
def add_labels(cmumosi_higlevel):
    cmumosi_highlevel.add_computational_sequences(mmdatasdk.cmu_mosi.labels,
                                                  'cmumosi/')
    cmumosi_highlevel.align('Opinion Segment Labels')
    deploy_files = {
        x: x
        for x in cmumosi_highlevel.computational_sequences.keys()
    }
    cmumosi_highlevel.deploy('aligned/', deploy_files)
    aligned_cmumosi_highlevel = mmdatasdk.mmdataset('aligned/')
    return (cmumosi_higlevel)
Пример #4
0
    return np.average(features, axis=0)


def directory_check(dirName):
    exists = True
    if os.path.exists(dirName) and os.path.isdir(dirName):
        if not os.listdir(dirName):
            print("MOSEI Directory is empty")
            exists = False
        else:
            print("MOSEI Directory is not empty")
    else:
        print("MOSEI Directory doesn't exist")
        exists = False
    return exists


cmumosei_path = '/ssd/speech_data/cmumosei/'

if directory_check(cmumosei_path):
    # aling CMU-MOSEI
    cmumosei_highlevel = ReadDlData(mmdatasdk.cmu_mosei.highlevel, cmumosei_path)

    cmumosei_highlevel.align('glove_vectors', collapse_functions=[average])
    cmumosei_highlevel.add_computational_sequences(mmdatasdk.cmu_mosei.labels, 'cmumosei/')

    cmumosei_highlevel.align('Sentiment Labels')    # 'Emotion Labels' available as well
    deploy_files = {x:x for x in cmumosei_highlevel.computational_sequences.keys()}
    cmumosei_highlevel.deploy('mosei_aligned/', deploy_files)
    aligned_cmumosei_highlevel = mmdatasdk.mmdataset('mosei_aligned/')
Пример #5
0
            print("MOSI Directory is not empty")
    else:
        print("MOSI Directory doesn't exist")
        exists = False
    return (exists)


BASE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
cmumosi_path = os.path.join(BASE_PATH, 'cmumosi')
aligned_path = os.path.join(BASE_PATH, 'aligned')
print("preaparing CMU MOSI download")

if not directory_check(cmumosi_path):
    ## execute the following command only once
    print(".....mosi is being downloaded")
    cmumosi_highlevel = mmdatasdk.mmdataset(mmdatasdk.cmu_mosi.highlevel,
                                            'cmumosi/')
else:
    print("mosi is already downloaded")
    cmumosi_highlevel = ReadDlData(mmdatasdk.cmu_mosi.highlevel, cmumosi_path)

cmumosi_highlevel.align('glove_vectors', collapse_functions=[myavg])
cmumosi_highlevel.add_computational_sequences(mmdatasdk.cmu_mosi.labels,
                                              'cmumosi/')
size_list = [9216, 74, 47, 300, 1585]

cmumosi_highlevel.align('Opinion Segment Labels')
deploy_files = {x: x for x in cmumosi_highlevel.computational_sequences.keys()}
cmumosi_highlevel.deploy('aligned/', deploy_files)
aligned_cmumosi_highlevel = mmdatasdk.mmdataset('aligned/')

#cmumosi_highlevel = add_labels(cmumosi_highlev)