def __init__(self, parent, title, dir):
        ffp = FaceFileParser()
        ffp.add_dir(dir)
        data_imgs = ffp.get_data()
        wx.Frame.__init__(self, parent, title=title, size=(800, 650))

        self.imgs = [[], [], [], []]
        self.images = [[], [], [], []]

        for img in data_imgs:
            self.imgs[img[0]].append(img)

        for a in range(0, 4):
            self.images[a] = self.make_images(self.imgs[a])

        for a in range(0, 4):
            for b in range(0, len(self.images[a])):
                i = self.images[a][b].Scale(180, 36)
                i = i.ConvertToBitmap()
                wx.StaticBitmap(self, -1, i, (5 + (190 * a), 5 + (46 * b)))

        #i = self.images[0].Scale(240,80,wx.IMAGE_QUALITY_NORMAL)
        #self.show_img = wx.StaticBitmap(self,-1,i.ConvertToBitmap(),(5,5))
        #self.img_c = 0
        #self.next_b = wx.Button(self,label='Next',pos=(5,90))
        #self.Bind(wx.EVT_BUTTON,self.next_img,self.next_b)

        self.Show()
Пример #2
0
 def __init__(self,src_dir,dest_dir):
     ffp = FaceFileParser()
     ffp.add_dir(src_dir)
     data_imgs = ffp.get_data()
     self.img_lists = [[],[],[],[]]
     self.dest_dir = dest_dir
     
     for img in data_imgs:
         self.img_lists[img[0]].append(list(img[1]))
Пример #3
0
    def train(self, event):
        if self.train_f_name_tb.GetValue() != '':
            ffp = FaceFileParser()
            ffp.add_dir(self.train_f_name_tb.GetValue())
            datalist = ffp.get_data()

            layers = int(self.train_numLayers_tb.GetValue())
            nodes = int(self.train_numNodes_tb.GetValue())
            epochs = int(self.train_numEpochs_tb.GetValue())

            nettype = self.netbox.GetSelection()

            print layers
            print nodes
            print epochs
            print nettype

            if nettype == 0:
                fc = SupervisedFacialClassifier()
                if layers == 1:
                    errorData = fc.alternateTrain(datalist, [(nodes)], epochs,
                                                  5)
                elif layers == 2:
                    errorData = fc.alternateTrain(datalist, (nodes, nodes),
                                                  epochs, 5)
                elif layers == 3:
                    errorData = fc.alternateTrain(datalist,
                                                  (nodes, nodes, nodes),
                                                  epochs, 5)

                print 'ErrorData:\n'

                print errorData

                print '\n'

                for entry in errorData['training_error']:
                    print entry
            else:
                fc = UnsupervisedFacialClassifier(2, 2)
                errorData = fc.train(datalist)
Пример #4
0
    def train(self, event):
        if self.train_f_name_tb.GetValue() != '':
            ffp = FaceFileParser()
            ffp.add_dir(self.train_f_name_tb.GetValue())
            datalist = ffp.get_data()

            layers = int(self.train_numLayers_tb.GetValue())
            nodes = int(self.train_numNodes_tb.GetValue())
            epochs = int(self.train_numEpochs_tb.GetValue())

            nettype = self.netbox.GetSelection()

            print layers
            print nodes
            print epochs
            print nettype

            if nettype == 0:
                fc = SupervisedFacialClassifier()
                if layers == 1:
                    errorData = fc.alternateTrain(datalist, [(nodes)], epochs, 5)
                elif layers == 2:
                    errorData = fc.alternateTrain(datalist, (nodes,nodes), epochs, 5)
                elif layers == 3:
                    errorData = fc.alternateTrain(datalist, (nodes,nodes,nodes), epochs, 5)

                print 'ErrorData:\n'
                
                print errorData
                    
                print '\n'
                
                for entry in errorData['training_error']:
                    print entry
            else:
                fc = UnsupervisedFacialClassifier(2,2)
                errorData = fc.train(datalist)
Пример #5
0
    for data_dir in os.walk(root_data_dir):
        (dirname, subdirs, files) = data_dir
        dirs_to_test.append(dirname)

# Write the trial data out to a file
outfile = open(outfile_name, 'w')
outfile.write(
    "DIRNAME, LEARNINGRATE, DECAY, EPOCHS, TRAINING_ERR, TRAINING_ERR_STD, TESTING_ERR, TESTING_ERR_STD\n"
)

for dirname in dirs_to_test:
    for learningrate in learningrates_to_test:
        for neighbourdecay in neighbourdecays_to_test:
            for epochs in epochs_to_test:

                ffp = FaceFileParser(verbose=False)
                ffp.add_dir(dirname)
                datalist = ffp.get_data()

                print "################################"
                print " %s, learningrate: %s, decay: %s, epochs: %s" %\
                  (dirname, learningrate, neighbourdecay, epochs)
                trial_avg_testing_err = []
                trial_avg_training_err = []

                # Run trials
                for trial in range(num_trials):
                    print "Trial #%i" % trial
                    fc = UnsupervisedFacialClassifier(2, 2, 0.01)
                    train_perf = fc.train(datalist,
                                          epochs,
Пример #6
0
import wx
from face_sampling_ui import FaceSamplerFrame
from face_file_parser import FaceFileParser
from supervised_facial_classifier import SupervisedFacialClassifier


ffp = FaceFileParser()
ffp.add_dir("./inputData")
# ffp.add_dir("./normData")

datalist = ffp.get_data()
"""
print "Single Hidden Layer"
for i in range(2,20):
    fc = FacialClassifier()
    fc.alternateTrain(datalist, [(i)], 25)

print "Double Hidden Layer"
for i in range(2,20):
    fc = FacialClassifier()
    fc.alternateTrain(datalist, (i,i), 25)

print "Triple Hidden Layer"
for i in range(2,20):
    fc = FacialClassifier()
    fc.alternateTrain(datalist, (i,i,i), 25)
"""
fc = SupervisedFacialClassifier()
# alternateTrain(datalist, hiddenNodes, #epochs, log stats every X epochs)
fc.alternateTrain(datalist, (20, 20), 500, 10)
Пример #7
0
import wx
from face_sampling_ui import FaceSamplerFrame
from face_file_parser import FaceFileParser
from supervised_facial_classifier import SupervisedFacialClassifier


ffp = FaceFileParser()
ffp.add_dir("./inputData")
#ffp.add_dir("./normData")

datalist = ffp.get_data()
"""
print "Single Hidden Layer"
for i in range(2,20):
    fc = FacialClassifier()
    fc.alternateTrain(datalist, [(i)], 25)

print "Double Hidden Layer"
for i in range(2,20):
    fc = FacialClassifier()
    fc.alternateTrain(datalist, (i,i), 25)

print "Triple Hidden Layer"
for i in range(2,20):
    fc = FacialClassifier()
    fc.alternateTrain(datalist, (i,i,i), 25)
"""
fc = SupervisedFacialClassifier()
# alternateTrain(datalist, hiddenNodes, #epochs, log stats every X epochs)
fc.alternateTrain(datalist, (20,20), 500, 10);
Пример #8
0
else: 
  # For all leaf-node directories under the specified path we run trials
  for data_dir in os.walk(root_data_dir):
    (dirname, subdirs, files) = data_dir
    dirs_to_test.append(dirname)

# Write the trial data out to a file
outfile = open(outfile_name, 'w')
outfile.write("DIRNAME, LEARNINGRATE, DECAY, EPOCHS, TRAINING_ERR, TRAINING_ERR_STD, TESTING_ERR, TESTING_ERR_STD\n")

for dirname in dirs_to_test:
  for learningrate in learningrates_to_test:
    for neighbourdecay in neighbourdecays_to_test:
      for epochs in epochs_to_test:

        ffp = FaceFileParser(verbose=False)
        ffp.add_dir(dirname)
        datalist = ffp.get_data()

        print "################################"
        print " %s, learningrate: %s, decay: %s, epochs: %s" %\
          (dirname, learningrate, neighbourdecay, epochs)
        trial_avg_testing_err = []
        trial_avg_training_err = []

        # Run trials
        for trial in range(num_trials):
          print "Trial #%i" % trial
          fc = UnsupervisedFacialClassifier(2,2, 0.01)
          train_perf = fc.train(datalist, epochs, test_proportion=0.25, verbose=False)
Пример #9
0
from face_file_parser import FaceFileParser
from supervised_facial_classifier import SupervisedFacialClassifier

max_hn = 400
min_hn = 50
step_size = 25
epochs = 750
output = 50

ffp = FaceFileParser()
sfc = SupervisedFacialClassifier()
ffp.add_dir('./normData')
d_s = ffp.get_data()

csv_out = open('./vary_topology.csv','w')
csv_out.write('topology,min test error,at epoch,avg test error,avg train error\n')

l1 = min_hn
while l1 <= max_hn:
    print 'Topology :' + str(l1) + '\n'
    results = sfc.alternateTrain(d_s,[(l1)],epochs,logFreq=output)
    min_err = min(results['testing_error'])
    at_e = results['epochs'][results['testing_error'].index(min_err)]
    avg_tst = results['avg_testing_error']
    avg_trn = results['avg_training_error']
    csv_out.write(str(l1) + ';' + ',' + str(min_err) + ','
    + str(at_e) + ',' + str(avg_tst) + ',' + str(avg_trn) + '\n')
    print 'Minimum error of ' + str(min_err) + ' at epoch ' + str(at_e)

    l2 = min_hn
    while l2 <= max_hn: