Esempio n. 1
0
# 랜덤하게 이미지를 한장 뽑아내는 함수
np.random.seed = 100


def random_test_image():
    """Pick a random test image from the test directory"""
    c = np.random.choice(cat_df['category'])
    root = testdir + c + '/'
    img_path = root + np.random.choice(os.listdir(root))
    return img_path


# 랜덤하게 이미지를 선택한 후 Top5 예측치를 확인하는 함수
train_util.display_prediction(random_test_image(),
                              model,
                              topk=5,
                              model_name=model_choice)
time.sleep(1.5)
train_util.display_prediction(random_test_image(),
                              model,
                              topk=5,
                              model_name=model_choice)
time.sleep(1.5)
train_util.display_prediction(random_test_image(),
                              model,
                              topk=5,
                              model_name=model_choice)
time.sleep(1.5)
train_util.display_prediction(random_test_image(),
                              model,
                              topk=5,
Esempio n. 2
0
# 랜덤하게 이미지를 한장 뽑아내는 함수
np.random.seed = 100


def random_test_image():
    """Pick a random test image from the test directory"""
    c = np.random.choice(cat_df['category'])
    root = testdir + c + '/'
    img_path = root + np.random.choice(os.listdir(root))
    return img_path


avg_inference_time = 0
# 랜덤하게 이미지를 선택한 후 Top5 예측치를 확인하는 함수
avg_inference_time += train_util.display_prediction(random_test_image(),
                                                    model,
                                                    topk=5,
                                                    model_name=model_choice)
time.sleep(1.5)
avg_inference_time += train_util.display_prediction(random_test_image(),
                                                    model,
                                                    topk=5,
                                                    model_name=model_choice)
time.sleep(1.5)
avg_inference_time += train_util.display_prediction(random_test_image(),
                                                    model,
                                                    topk=5,
                                                    model_name=model_choice)
time.sleep(1.5)
avg_inference_time += train_util.display_prediction(random_test_image(),
                                                    model,
                                                    topk=5,
Esempio n. 3
0
    # 랜덤하게 이미지를 한장 뽑아내는 함수
    np.random.seed = 100

    def random_test_image():
        """Pick a random test image from the test directory"""
        c = np.random.choice(cat_df['category'])
        root = testdir + c + '/'
        img_path = root + np.random.choice(os.listdir(root))
        return img_path

    avg_inference_time = 0
    # 랜덤하게 이미지를 선택한 후 Top5 예측치를 확인하는 함수
    for a in range(10):
        avg_inference_time += train_util.display_prediction(
            random_test_image(),
            model,
            topk=5,
            model_name=model_choice,
            etc='[K_' + str(K_fold) + '_' + str(k) + '_fold] ')
        time.sleep(1.1)

    total_avg_inference_time += avg_inference_time

    print(f'총 10회 추론시간 평균 : {avg_inference_time*1000.0/10:.2f}ms')

    results.append(
        train_util.evaluate(model, dataloaders['test'], criterion, n_classes))
    results[k] = results[k].merge(
        cat_df, left_on='class',
        right_on='category').drop(columns=['category'])

    results[k].sort_values('top1', ascending=False, inplace=True)