Ejemplo n.º 1
0
def createInitialDatasets():
    print "Creating data sets"
    t0 = time.time()

    datasetDict = {}

    dataFile = h5py.File(dataFileName, 'r')
    mapCoord['x1'] = len(dataFile['bed'][:][0])
    mapCoord['y1'] = len(dataFile['bed'][:])
    mapCoord['proj_x1'] = dataFile['x'][:][-1]
    mapCoord['proj_y1'] = dataFile['y'][:][-1]

    surfaceX = Dataset('surfaceGradX')
    surfaceY = Dataset('surfaceGradY')
    datasetDict['surfaceGradX'] = surfaceX
    datasetDict['surfaceGradY'] = surfaceY

    velocity = Dataset('velocity')
    datasetDict['velocity'] = velocity

    smb = Dataset('smb')
    datasetDict['smb'] = smb

    bed = Dataset('bed')
    datasetDict['bed'] = bed

    surface = Dataset('surface')
    datasetDict['surface'] = surface

    thickness = Dataset('thickness')
    datasetDict['thickness'] = thickness

    t2m = Dataset('t2m')
    datasetDict['t2m'] = t2m

    datasetDict['x'] = Dataset('x')
    datasetDict['y'] = Dataset('y')

    dataFile.close()

    print "Loaded all data sets in ", time.time() - t0, " seconds"
    return datasetDict
def test3():
    d = sentences()
    literals = []
    literals.append([d['not_a'], d['c']])
    literals.append([d['not_b'], d['c']])
    literals.append([d['a'], d['b']])
    clauses = create_clauses(literals)

    not_observable_fact = [d['not_c']]

    not_observable_clause = Clause(not_observable_fact)

    clauses.append(not_observable_clause)
    dataset = Dataset(clauses)
    return dataset
Ejemplo n.º 3
0
def createInitialDataSets():
    print "Creating data sets"
    t0 = time.time()

    datasetDict = {}
    """
    Read in dimensions of bed
    at point of comment x = 1670, y = 2991
    read in last values of x and y and map to the object map
    """
    dataFile = h5py.File(dataFileName, 'r')
    map['x1'] = len(dataFile['bed'][:][0])
    map['y1'] = len(dataFile['bed'][:])
    map['proj_x1'] = dataFile['x'][:][-1]
    map['proj_y1'] = dataFile['y'][:][-1]

    velocity = Dataset('velocity', greenPlotPen)
    datasetDict['velocity'] = velocity

    smb = Dataset('smb', redPlotPen)
    datasetDict['smb'] = smb

    bed = Dataset('bed', bluePlotPen)
    datasetDict['bed'] = bed

    surface = Dataset('surface', greyPlotPen)
    datasetDict['surface'] = surface

    thickness = Dataset('thickness', orangePlotPen)
    datasetDict['thickness'] = thickness

    t2m = Dataset('t2m', tealPlotPen)
    datasetDict['t2m'] = t2m

    dataFile.close()

    print "Loaded all data sets in ", time.time() - t0, " seconds"
    return datasetDict
Ejemplo n.º 4
0
    def __init__(self):
        super(DatasetGui, self).__init__()
        self.setWindowTitle("Pointing Gesture Recognition - Dataset recording")

        # Retrieve all settings
        self.settings = Settings()

        # Load sounds
        self.countdownSound = QtMultimedia.QSound(
            self.settings.getResourceFolder() + "countdown.wav")
        self.countdownEndedSound = QtMultimedia.QSound(
            self.settings.getResourceFolder() + "countdown-ended.wav")

        # Get the context and initialise it
        self.context = Context()
        self.context.init()

        # Create the depth generator to get the depth map of the scene
        self.depth = DepthGenerator()
        self.depth.create(self.context)
        self.depth.set_resolution_preset(RES_VGA)
        self.depth.fps = 30

        # Create the image generator to get an RGB image of the scene
        self.image = ImageGenerator()
        self.image.create(self.context)
        self.image.set_resolution_preset(RES_VGA)
        self.image.fps = 30

        # Create the user generator to detect skeletons
        self.user = UserGenerator()
        self.user.create(self.context)

        # Initialise the skeleton tracking
        skeleton.init(self.user)

        # Start generating
        self.context.start_generating_all()
        print "Starting to detect users.."

        # Create a new dataset item
        self.data = Dataset()

        # Create a timer for an eventual countdown before recording the data
        self.countdownTimer = QtCore.QTimer()
        self.countdownRemaining = 10
        self.countdownTimer.setInterval(1000)
        self.countdownTimer.setSingleShot(True)
        self.countdownTimer.timeout.connect(self.recordCountdown)

        # Create a timer to eventually record data for a heat map
        self.heatmapRunning = False
        self.heatmapTimer = QtCore.QTimer()
        self.heatmapTimer.setInterval(10)
        self.heatmapTimer.setSingleShot(True)
        self.heatmapTimer.timeout.connect(self.recordHeatmap)

        # Create the global layout
        self.layout = QtWidgets.QVBoxLayout(self)

        # Create custom widgets to hold sensor's images
        self.depthImage = SensorWidget()
        self.depthImage.setGeometry(10, 10, 640, 480)

        # Add these custom widgets to the global layout
        self.layout.addWidget(self.depthImage)

        # Hold the label indicating the number of dataset taken
        self.numberLabel = QtWidgets.QLabel()
        self.updateDatasetNumberLabel()

        # Create the acquisition form elements
        self.createAcquisitionForm()

        # Register a dialog window to prompt the target position
        self.dialogWindow = DatasetDialog(self)

        # Allow to save the data when the right distance is reached
        self.recordIfReady = False

        # Create and launch a timer to update the images
        self.timerScreen = QtCore.QTimer()
        self.timerScreen.setInterval(30)
        self.timerScreen.setSingleShot(True)
        self.timerScreen.timeout.connect(self.updateImage)
        self.timerScreen.start()
Ejemplo n.º 5
0
from classes import Dataset
from classes import Classifier
from classes import Classifier_random
from classes import Generation
from classes import First_Generation
import time
import pickle

t = time.time()
data_1 = '\\flowers\\daisy'
data_2 = '\\flowers\\tulip'
data = Dataset(data_1, data_2)
#with open('test_dataset.pickle', 'rb') as handle:
#    data = pickle.load(handle)

print('---Data Loaded(' + str(round(time.time() - t, 2)) + 's)---\n')

t = time.time()
g = First_Generation(
    500)  #The number of individuals in all the generations is the same
g.evaluate(data)
print(f'Génération 1  ({round(time.time()-t,2)}s)')
print(g)

for i in range(2, 100):
    t = time.time()
    g = g.make_new_gen(150, mutation_rate=0.005)
    g.evaluate(data)
    print(f'\nGénération {i}  ({round(time.time()-t,2)}s)')
    print(g)
Ejemplo n.º 6
0
def remove_duplicate_clauses(dataset):
    new_clauses = list(set(dataset.clauses))
    new_dataset = Dataset(new_clauses)
    return new_dataset
Ejemplo n.º 7
0
    if not os.path.isdir(name_exp + "/models"): os.mkdir(name_exp + "/models")

    #CUDA
    use_cuda = torch.cuda.is_available()
    device = torch.device("cuda:0" if use_cuda else "cpu")
    torch.backends.cudnn.benchmark = True

    params = {'batch_size': 64, 'shuffle': True, 'num_workers': 6}

    #Dataset
    partition = create_partition_dict(list_utt_id, [])
    spk_id_att_labels = txt_2_dict(att_labels_txt)
    labels = create_labels_dict(list_utt_id, [], spk_id_att_labels)

    #Generators
    training_set = Dataset(partition['train'], labels, data_file, prob_file)

    generator = data.DataLoader(training_set, **params)

    # Layer dimension
    input_dim = 512
    latent_dim = 128

    input_dim_discrim = latent_dim
    hidden_dim_discrim = 128

    model_ae = Autoencoder(input_dim, latent_dim)
    optimizer_ae = torch.optim.SGD(model_ae.parameters(),
                                   lr=0.0001,
                                   momentum=0.9)
    model_ae.to(device)