Ejemplo n.º 1
0
# coding: utf-8

# In[1]:

import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.path.abspath('.'), '../../')))
from keras.models import load_model
from src.limit import limitUsage
limitUsage("3")

# In[2]:

import pandas as pd
import random
import numpy as np
import cv2
import os
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
import threading
import shutil


def get_train_data(train_file):
    ## 20% for testing
    df = pd.read_csv(train_file)
    n = int(df.shape[0] * .8)
    label_train = df.iloc[:n, -1]
    df_train = df.iloc[:n, :]
    df_test = df.iloc[n:, :]
    label_test = df.iloc[n:, -1]
Ejemplo n.º 2
0
## clean the test and train file
import csv
from src.config.staticConfig import StaticConfig
from src.data.dataRep import Image
import os
from src.limit import limitUsage
## to avoid accidental  gpu usage
limitUsage("5,6")


def is_valid(urls, is_train):
    for url in urls:
        if not os.path.exists(StaticConfig.getImagePath(url, is_train)):
            return False
    return True


all_valid_entries = {}


def get_key(is_train, row, index):
    return '_'.join(row[index:index + 5]) + '_' + str(is_train)


def get_processed_file_name(is_train, row, index):
    key = get_key(is_train, row, index)
    if (key in all_valid_entries):
        return all_valid_entries[key]
    start_index = index * 5
    img = Image(row[start_index], row[start_index + 1], row[start_index + 2],
                row[start_index + 3], row[start_index + 4], False)
import sys
sys.path.append('..')
from data.dataRep import FCEXPDataSet
from config.staticConfig import StaticConfig
from src.limit import limitUsage
### Command line options should be added in future

limitUsage("7")
## download images from the url
trainEntries = FCEXPDataSet(StaticConfig.getTrainCSVPath())
#trainEntries.downloadImages()
trainEntries.cutImages()
del trainEntries
testEntries = FCEXPDataSet(StaticConfig.getTestCSVPath(), "test")
testEntries.cutImages()
#testEntries.downloadImages()
del testEntries
# coding: utf-8

# In[16]:

import sys
import os

sys.path.append(os.path.abspath(os.path.join(os.path.abspath('.'), '../../')))
from keras.models import load_model
from src.limit import limitUsage

limitUsage("2")

# In[17]:

modelFile = '../model/keras/model/facenet_keras.h5'
# faceNetModel = load_model(modelFile)

# In[18]:

#faceNetModel.summary()

# In[19]:

facenet_model = load_model(modelFile)

# In[20]:

#!pip install git+https://www.github.com/keras-team/keras-contrib.git
#!pwd
Ejemplo n.º 5
0
# coding: utf-8

# In[16]:

import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.path.abspath('.'), '../../')))
from keras.models import load_model
from src.limit import limitUsage
limitUsage("5")

# In[17]:

modelFile = '../model/keras/model/facenet_keras.h5'
# faceNetModel = load_model(modelFile)

# In[18]:

#faceNetModel.summary()

# In[19]:

facenet_model = load_model(modelFile)

# In[20]:

#!pip install git+https://www.github.com/keras-team/keras-contrib.git
#!pwd

# In[42]: