예제 #1
0
def gen_deeper_pipeline_predictor_test(tongue_image_arrays,
                                       tongue_yaofangs,
                                       tongue_image_shape,
                                       nb_yao,
                                       trained_gen_model,
                                       use_tfidf_tensor=False):
    '''
    @param use_tfidf_tensor: flag of use tfidf tensor or not with different tensorization function
    '''
    ''' load test_x & test_y '''
    if use_tfidf_tensor == True:
        total_x, total_y = tongue2text_gen.data_tensorization_tfidf(
            tongue_image_arrays, tongue_yaofangs, tongue_image_shape, nb_yao)
    else:
        total_x, total_y = tongue2text_gen.data_tensorization(
            tongue_image_arrays, tongue_yaofangs, tongue_image_shape, nb_yao)

#     test_x = total_x[: 500]
#     test_x = total_x[2000 : 2500]
#     test_x = total_x[4000 : 4500]
#     test_x = total_x[6000 : 6500]
    test_x = total_x[len(total_x) - 500:]

    gen_output = tongue2text_gen.predictor(trained_gen_model, test_x)

    return gen_output
def gen_biggertimes_cnn_withlda_predictor_test(tongue_image_arrays, tongue_yaofangs, tongue_image_shape, nb_yao, trained_gen_model,
                                               lda_model_path, use_tfidf_tensor=False):
    '''
    @param use_tfidf_tensor: flag of use tfidf tensor or not with different tensorization function
    @return: gen_output_list: [gen_output, aux_output]
    '''

    # in test process, lda_model and dictionary can be only load from disk(can
    # not be replaced)
    lda_model, dictionary = lda.loadModelfromFile(
        lda_model_path, readOnly=True)

    total_tongue_x, total_y, total_aux_y = tongue2text_gen.data_tensorization_lda(
        tongue_image_arrays, tongue_yaofangs, tongue_image_shape, nb_yao, lda_model.num_topics,
        lda_model, dictionary, use_tfidf_tensor=use_tfidf_tensor)

#     test_tongue_x = total_tongue_x[: 500]
#     test_tongue_x = total_tongue_x[2000 : 2500]
#     test_tongue_x = total_tongue_x[4000 : 4500]
#     test_tongue_x = total_tongue_x[6000 : 6500]
    test_tongue_x = total_tongue_x[len(total_tongue_x) - 500:]

    gen_output_list = tongue2text_gen.predictor(
        trained_gen_model, test_tongue_x)
    # gen_output in here is a tuple as (main_output, aux_output), get the
    # first one

    return gen_output_list