Esempio n. 1
0
def test(chosenAlgo):
    global algoName
    global success
    global failure
    global accuracy
    global singleTime
    global totalTime
    global countHits
    global trainLength
    global testLength
#    global intermediate
    
    algoName = chosenAlgo
    print database, testName, algoName
    if(algoName == "eigenface"):
        if(database == "yale A"):
            if(testName == "choice"):
                global testing
                global testing
                global training_answer
                global W
                global mu
                global projections
                global testing_answer
                print "FETCHING TEST IMAGES"
                testing, training_answer, W, mu, projections, testing_answer = eigenfaces.test_yale(testName)
                print testing_answer
                return render_template("choice.html",images =  testing_answer, db = "/static/images/yalefaces/")
            else:
                failure, success, accuracy, singleTime, totalTime, trainLength, testLength, countHits= eigenfaces.test_yale(testName)
                print countHits
        elif(database == "yale B"):
            pass
        elif(database == "orl"):
            if(testName == "choice"):
                global testing
                global testing
                global training_answer
                global W
                global mu
                global projections
                global testing_answer
                testing, training_answer, W, mu, projections, testing_answer = eigenfaces.test_orl(testName)
                return render_template("choice.html", images = testing_answer, db = "/static/images/orl_faces/")
            else:
                failure, success, accuracy, singleTime, totalTime, trainLength, testLength, countHits = eigenfaces.test_orl(testName)        
    elif(algoName == "fisherface"):
        if(database == "yale A"):
            if(testName == "choice"):
                global testing
                global testing
                global training_answer
                global W
                global mu
                global projections
                global testing_answer
                testing, training_answer, W, mu, projections, testing_answer = fisherfaces.test_yale(testName)
                return render_template("choice.html", images =  testing_answer, db = "/static/images/yalefaces/")
            else:
                failure, success, accuracy, singleTime, totalTime, trainLength, testLength, countHits = fisherfaces.test_yale(testName)
        elif(database == "yale B"):
            pass
        elif(database == "orl"):
            if(testName == "choice"):
                global testing
                global testing
                global training_answer
                global W
                global mu
                global projections
                global testing_answer
                testing, training_answer, W, mu, projections, testing_answer = fisherfaces.test_orl(testName)
                return render_template("choice.html", images= testing_answer, db = "/static/images/orl_faces/")
            else:
                failure, success, accuracy, singleTime, totalTime, trainLength, testLength, countHits = fisherfaces.test_orl(testName)
    elif(algoName == "sift"):
        if(database == "yale A"):
            if(testName == "choice"):
                global descriptors_testing
                global training_answer
                global descriptors_training
                global testing_answer
                descriptors_testing, training_answer, descriptors_training, testing_answer = sift.test_yale(testName)
                return render_template("choice.html", images= testing_answer, db = "/static/images/yalefaces/")
            else:
                failure, success, accuracy, singleTime, totalTime, trainLength, testLength, countHits = sift.test_yale(testName)
        elif(database == "yale B"):
            pass
        elif(database == "orl"):
            if(testName == "choice"):
                global descriptors_testing
                global training_answer
                global descriptors_training
                global testing_answer
                descriptors_testing, training_answer, descriptors_training, testing_answer = sift.test_orl(testName)
                return render_template("choice.html",images= testing_answer, db="/static/images/orl_faces/")
            else:
                failure, success, accuracy, singleTime, totalTime, trainLength, testLength, countHits = sift.test_orl(testName)
    elif(algoName == "lem"):
        if(database == "yale A"):
            if(testName == "choice"):
                global testing_corners
                global training_corners
                global training_answer
                global testing_answer
                testing_corners, training_corners, training_answer, testing_answer = lem.test_yale(testName)
                return render_template("choice.html",images= testing_answer, db="/static/images/yalefaces/")
            else:
                failure, success, accuracy, singleTime, totalTime, trainLength, testLength, countHits = lem.test_yale(testName)
        elif(database == "yale B"):
            pass
        elif(database == "orl"):
            if(testName == "choice"):
                global testing_corners
                global training_corners
                global training_answer
                global testing_answer
                testing_corners, training_corners, training_answer, testing_answer = lem.test_orl(testName)
                return render_template("choice.html",images= testing_answer, db="/static/images/orl_faces/")
            else:
                failure, success, accuracy, singleTime, totalTime, trainLength, testLength, countHits = lem.test_orl(testName)
    acc=str(accuracy)[:6]+"%" 
    print acc
    return render_template("chooseResult.html",accuracy=acc, singleTime=singleTime, totalTime=totalTime, training_set_length=trainLength, testing_set_length=testLength, countHits=countHits)
Esempio n. 2
0
    def faceRec(self,name):
        if(name=="eigenface"):
            self.algoName = "eigenface"
            if(self.db == "yale"):
                    if(self.testName=="choice"):
                        self.testing, self.training_answer, self.W, self.mu, self.projections, self.testing_answer = eigenfaces.test_yale(self.testName)
                        self.choiceImage = "Eigenface_choice_yale"
                    else:
                        image1, image2, accuracy = eigenfaces.test_yale(self.testName)
            elif(self.db == "orl"):
                    if(self.testName=="choice"):
                        self.testing, self.training_answer, self.W, self.mu, self.projections, self.testing_answer = eigenfaces.test_orl(self.testName)
                        self.choiceImage = "Eigenface_choice_orl"
                    else:
                        image1, image2, accuracy = eigenfaces.test_orl(self.testName)                        
            elif(self.db == "db3"):
                pass
            if(self.testName=="choice"):
                self.testImage =''
                self.choiceFrame()
            else:
                print image1, image2
                self.eigenface_success = tk.Frame(self)
                self.eigenface_fail = tk.Frame(self)
                self.eigenface_intermediate = tk.Frame(self)

                self.eigenface_success.place(in_=self.eigenface, x=250, y=120, relwidth=1, relheight=1)
                self.eigenface_fail.place(in_=self.eigenface, x=250, y=120, relwidth=1, relheight=1)            
                self.eigenface_intermediate.place(in_=self.eigenface, x=250, y=120, relwidth=1, relheight=1)

                eigenButton1 = tk.Button(self.eigenface, text = "Success", command=lambda:self.eigenface_success.lift())
                eigenButton2 = tk.Button(self.eigenface, text = "Failure", command=lambda:self.eigenface_fail.lift())
                eigenButton3 = tk.Button(self.eigenface, text = "Intermediate", command=lambda:self.eigenface_intermediate.lift())
    
                eigenButton4 = tk.Button(self.eigenface, text="Back",command=lambda:self.remove(eigenButton1, eigenButton2, eigenButton3, eigenButton4))

                eigenButton1.pack(side="top")
                eigenButton2.pack(side="top")
                eigenButton3.pack(side="top")
        
                eigenButton4.pack(side="top")

                failure = ImageTk.PhotoImage(file=image1)
                success = ImageTk.PhotoImage(file=image2)
                labelFail = tk.Label(self.eigenface_fail, image = failure)
                labelFail.image = failure
                labelFail.pack(side="left")
                labelSuccess = tk.Label(self.eigenface_success, image = success)
                labelSuccess.image = success
                labelSuccess.pack(side="left")
                self.eigenface.lift()

        elif(name=="fisherface"):
            self.algoName = "fisherface"
            if(self.db == "yale"):
                    if(self.testName=="choice"):
                        self.testing, self.training_answer, self.W, self.mu, self.projections, self.testing_answer = fisherfaces.test_yale(self.testName)
                        self.choiceImage = "Fisherface_choice_yale"
                    else:
                        image1, image2, accuracy = fisherfaces.test_yale(self.testName)
            elif(self.db == "orl"):
                    if(self.testName=="choice"):
                        self.testing, self.training_answer, self.W, self.mu, self.projections, self.testing_answer = fisherfaces.test_orl(self.testName)
                        self.choiceImage = "Fisherface_choice_orl"
                    else:
                        image1, image2, accuracy = fisherfaces.test_orl(self.testName)                        
            elif(self.db == "db3"):
                pass
            if(self.testName=="choice"):
                self.choiceFrame()
            else:
                print image1, image2
                self.fisherface_success = tk.Frame(self)
                self.fisherface_fail = tk.Frame(self)
                self.fisherface_intermediate = tk.Frame(self)

                self.fisherface_success.place(in_=self.fisherface, x=250, y=100, relwidth=1, relheight=1)
                self.fisherface_fail.place(in_=self.fisherface, x=250, y=100, relwidth=1, relheight=1)            
                self.fisherface_intermediate.place(in_=self.fisherface, x=250, y=100, relwidth=1, relheight=1)

                fisherButton1 = tk.Button(self.fisherface, text = "Success", command=lambda:self.fisherface_success.lift())
                fisherButton2 = tk.Button(self.fisherface, text = "Failure", command=lambda:self.fisherface_fail.lift())
                fisherButton3 = tk.Button(self.fisherface, text = "Intermediate", command=lambda:self.fisherface_intermediate.lift())
    
                fisherButton4 = tk.Button(self.fisherface, text="Back",command=lambda:self.remove(fisherButton1, fisherButton2, fisherButton3, fisherButton4))
                fisherButton1.pack(side="top")
                fisherButton2.pack(side="top")
                fisherButton3.pack(side="top")
        
                fisherButton4.pack(side="top")
        
                failure = ImageTk.PhotoImage(file=image1)
                success = ImageTk.PhotoImage(file=image2)
                labelFail = tk.Label(self.fisherface_fail, image = failure)
                labelFail.image = failure
                labelFail.pack(side="left")
                labelSuccess = tk.Label(self.fisherface_success, image = success)
                labelSuccess.image = success
                labelSuccess.pack(side="left")
                self.fisherface.lift()

        elif(name=="sift"):
            self.algoName = "sift"
            if(self.db == "yale"):
                image1, image2, accuracy = sift.test_yale(self.testName)
            elif(self.db == "orl"):
                image1, image2, accuracy = sift.test_orl(self.testName)
            elif(self.db == "db3"):
                pass            
            print image1, image2
            self.sift_success = tk.Frame(self)
            self.sift_fail = tk.Frame(self)
            self.sift_intermediate = tk.Frame(self)

            self.sift_success.place(in_=self.sift, x=250, y=100, relwidth=1, relheight=1)
            self.sift_fail.place(in_=self.sift, x=250, y=100, relwidth=1, relheight=1)            
            self.sift_intermediate.place(in_=self.sift, x=250, y=100, relwidth=1, relheight=1)
    
            siftButton1 = tk.Button(self.sift, text = "Success", command=lambda:self.sift_success.lift())
            siftButton2 = tk.Button(self.sift, text = "Failure", command=lambda:self.sift_fail.lift())
            siftButton3 = tk.Button(self.sift, text = "Intermediate", command=lambda:self.sift_intermediate.lift())
    
            siftButton4 = tk.Button(self.sift, text="Back",command=lambda:self.remove(siftButton1, siftButton2, siftButton3, siftButton4))

            siftButton1.pack(side="top")
            siftButton2.pack(side="top")
            siftButton3.pack(side="top")
    
            siftButton4.pack(side="top")

            failure = ImageTk.PhotoImage(file=image1)
            success = ImageTk.PhotoImage(file=image2)
            labelFail = tk.Label(self.sift_fail, image = failure)
            labelFail.image = failure
            labelFail.pack(side="left")
            labelSuccess = tk.Label(self.sift_success, image = success)
            labelSuccess.image = sugridccess
            labelSuccess.pack(side="left")
            self.sift.lift()

        elif(name=="lem"):
            self.algoName = "lem"
            if(self.db == "yale"):
                pass
            elif(self.db == "orl"):
                pass
            elif(self.db == "db3"):
                pass
            self.lem.lift()