Beispiel #1
0
def predictAll():
    predictions = []
    pictures = glob.glob(testFileDogs)
    count = len(pictures)
    i = 0
    for each in pictures:
        image = io.imread(each)
        image1 = v3(image)
        image2 = mobile(image)
        image1 = np.expand_dims(image1, axis=0)
        image2 = np.expand_dims(image2, axis=0)
        print("Predicting image " + str(i) + "/" + str(count))
        prediction1 = np.argmax(allv3.predict(image1))
        prediction2 = np.argmax(allmobile.predict(image2))
        if (prediction1 == prediction2):
            predictions.append([classesAll[prediction1], each.split('/')[-1]])
        else:
            predictions.append([
                classesAll[prediction1] + ' or ' + classesAll[prediction2],
                each.split('/')[-1]
            ])

        i += 1

    printall(predictions)
Beispiel #2
0
def model1():
    predictions = []
    pictures = glob.glob(testFile)
    count = len(pictures)
    i = 0
    for each in pictures:
        image = io.imread(each)
        image1 = v3(image)
        image2 = mobile(image)
        image1 = np.expand_dims(image1, axis=0)
        image2 = np.expand_dims(image2, axis=0)
        print("Predicting image " + str(i) + "/" + str(count))
        prediction1 = np.argmax(Cat_Dogv3.predict(image1))
        prediction2 = np.argmax(Cat_DogMobileNet.predict(image2))
        if (prediction1 == prediction2):
            if (prediction1 == 0):
                prediction3 = np.argmax(catv3.predict(image1))
                prediction4 = np.argmax(catmobile.predict(image2))
                if (prediction3 == prediction4):
                    race = classesCats[prediction3]
                else:
                    race = [classesCats[prediction3], classesCats[prediction4]]
            else:
                prediction3 = np.argmax(dogv3.predict(image1))
                prediction4 = np.argmax(dogmobile.predict(image2))
                if (prediction3 == prediction4):
                    race = classesDogs[prediction3]
                else:
                    race = [classesDogs[prediction3], classesDogs[prediction4]]
            predictions.append(
                [classesCatDog[prediction1], race,
                 each.split('/')[-1]])

        else:
            predictions.append(['Unsure', each.split('/')[-1]])
        i += 1

    printall(predictions)
Beispiel #3
0
def predictDogandCat():
    predictions = []
    pictures = glob.glob(testFile)
    count = len(pictures)
    i = 0
    for each in pictures:
        image = io.imread(each)
        image1 = v3(image)
        image2 = mobile(image)
        image1 = np.expand_dims(image1, axis=0)
        image2 = np.expand_dims(image2, axis=0)
        print("Predicting image " + str(i) + "/" + str(count))
        prediction1 = np.argmax(Cat_Dogv3.predict(image1))
        prediction2 = np.argmax(Cat_DogMobileNet.predict(image2))
        if (prediction1 == prediction2):
            predictions.append(
                [classesCatDog[prediction1],
                 each.split('/')[-1]])
        else:
            predictions.append(['Unsure', each.split('/')[-1]])
        i += 1

    printall(predictions)