Exemplo n.º 1
0
    def load_dataset(self, filename, load_dir):
        (dataset_embeddings, dataset_labels,
         dataset_imagepaths) = utilities.load_embeddings(
             load_path=load_dir, embed_filename=filename)

        print("Total Embeddings {}".format(np.array(dataset_embeddings).shape))
        print("Total Labels {}".format(np.array(dataset_labels).shape))
        print("Total Images {}".format(np.array(dataset_imagepaths).shape))

        return dataset_embeddings, dataset_labels, dataset_imagepaths
Exemplo n.º 2
0
                                   cv=cv,
                                   verbose=1,
                                   n_jobs=-1)

        # Fit the grid search to the data
        grid_search.fit(feat_train, lab_train)


if __name__ == '__main__':

    # Create the classifier
    gbm = GradientBoostMethod()

    # Load features and labels
    features, labels, ips = utilities.load_embeddings(
        load_path=gbm.args["embed_load_dir"],
        embed_filename=gbm.args["embed_filename"])

    # Train using default params
    ml_classifier = MLClassifier(ml_model=gbm.model, model_name=gbm.name)
    ml_classifier.train_classifier(features=features,
                                   labels=labels,
                                   save_model=gbm.args["save_model"],
                                   save_name=gbm.args["model_filename"])

    # Find the best params
    gbm.find_best_model_random(feat_train=features, lab_train=labels)
    gbm.find_best_model_grid(feat_train=features, lab_train=labels)

    # Train with best found params
    ml_classifier.set_model(ml_model=gbm.model)
Exemplo n.º 3
0
        df_full = pd.concat([df_features, df_labels], axis=1)
        df_full['label'] = df_full['label'].astype(str)
        #df_full.drop(df_full[df_full["label"] == "Indian"].index, inplace=True)

        # Plot
        sns.set_style("dark")

        fig.add_subplot(rows, cols, i + 1)
        sns.scatterplot(x='PC1',
                        y='PC2',
                        hue="label",
                        data=df_full,
                        palette=sns.color_palette("hls", colors),
                        alpha=.7,
                        legend="full",
                        x_jitter=20,
                        y_jitter=0).set_title(title)

    plt.show()


if __name__ == '__main__':

    dataset_embeddings, dataset_labels, dataset_imagepaths = utilities.load_embeddings(
        embed_filename="embeddings_ethnicity.pkl")
    plot_dimension_reduction(
        plots=["PCA", "TSNE", "ISO", "FICA", "LLE", "MDS"],
        features=dataset_embeddings,
        labels=dataset_labels,
        title="Face_Recognition")