Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

result of ###Running the Model in Course 1 - Part 8 - Lesson 3 - Notebook #105

Open
mazzingkaizer opened this issue May 27, 2020 · 0 comments

Comments

@mazzingkaizer
Copy link

mazzingkaizer commented May 27, 2020

Mr. Moroney, I always get a lot of help from your great courses. Thank you. ^^

The following is the result of ##Running the Model in Course 1 - Part 8 - Lesson 3 - which I modified and executed.
I modified the source code a little because I wanted to check the results on local PC.
The execution result is MISS CLASSIFICATION RATIO: 14.0625
This is the rate at which a horse image is judged to be human or a person image is judged to be a horse.
I think the rate of misjudgment is higher than expected.

How do I get this ratio close to zero percent?

------ modified source code "##Running the Model in Course 1 - Part 8 - Lesson 3 " -------
import numpy as np
#from google.colab import files
from tensorflow.keras.preprocessing import image

#uploaded = files.upload()
#for fn in uploaded.keys():

valid_image_list = [ { 'path': validation_horse_dir, 'images': os.listdir(validation_horse_dir) },
{ 'path': validation_human_dir, 'images': os.listdir(validation_human_dir) }]

total_image_cnt = len(os.listdir(validation_horse_dir)) + len(os.listdir(validation_human_dir))
miss_classification_count = 0
for valid_image in valid_image_list:
for image_name in valid_image['images']:
# predicting images
path = '{}/{}'.format(valid_image['path'], image_name)
#print("path:{}".format(path))
img = image.load_img(path, target_size=(300, 300))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)

    images = np.vstack([x])
    classes = model.predict(images, batch_size=10)
    #print(classes[0])
    if classes[0] > 0.5:
        if image_name.find("horse") > -1:
            miss_classification_count += 1
            res = "WRONG"
        else:
            res = "CORRECT"

        print("{} {} is a human : {}".format(classes[0], path, res))
    else:
        if image_name.find("human") > -1:
            miss_classification_count += 1
            res = "WRONG"
        else:
            res = "CORRECT"
        print("{} {} is a horse : {}".format(classes[0], path, res))

print("MISS CLASSIFICATION RATIO : {}".format((miss_classification_count / total_image_cnt) * 100))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant