Coder Social home page Coder Social logo

gabrielepicco / deep-learning-flower-identifier Goto Github PK

View Code? Open in Web Editor NEW
52.0 52.0 33.0 60 KB

Deep learning network to identify 102 different types of flowers

License: MIT License

Python 100.00%
google-colaboratory image-classification pytorch pytorch-scholarship-challenge

deep-learning-flower-identifier's People

Contributors

gabrielepicco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

deep-learning-flower-identifier's Issues

error 'cannot identify image file ' while loading the data for training

I have used your dataset to train my model, however, during the training, I got some errors related to some files, PIL.Image wasn't able to open some files, after some investigations, I found out that the file utility identify them as RIFF files, so I deleted every RIFF file and it works fine after that.
If anyone is going through this issue, here is a dataset which should work for you: https://www.kaggle.com/youben/flowers102species

Hard Coded Transformations

Hi Gabriel!
We shouldn't be applying hard coded transformations as such while testing, rather allow the user to define one and raise assertion error if they didn't :)

https://github.com/GabrielePicco/deep-learning-flower-identifier/blob/master/test_model_pytorch_facebook_challenge.py#L33-L38

Also somehow the code for calculating Accuracy wasn't working for me [PIL Register Decode Error even after applying the fix..],
don't know why, so we can replace that with this (self curated version plus someone shared this and i modified to meet my necessities)

data_dir = 'google_test_data'

#sample transformations
transformation = transforms.Compose([
    transforms.Resize((299,299)),
    transforms.CenterCrop(224),
    transforms.ToTensor(),
    transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])

image_dataset = datasets.ImageFolder(data_dir, transform= transformation)
dataloader = torch.utils.data.DataLoader(image_dataset, batch_size= 128, shuffle=True)

#######validation##########
# track valid loss
valid_loss = 0.0
class_correct = list(0. for i in range(102))
class_total   = list(0. for i in range(102))

model.eval().to(device)
# iterate over valid data
for data, target in dataloader:
    # move tensors to GPU if CUDA is available
    data, target = data.to(device), target.to(device)
    # forward pass: compute predicted outputs by passing inputs to the model
    output = model(data)
    _, pred = torch.max(output, 1)
    # compare predictions to true label
    correct_tensor = pred.eq(target.data.view_as(pred))
    correct = np.squeeze(correct_tensor.numpy()) if not device else np.squeeze(correct_tensor.cpu().numpy())
    # calculate valid accuracy for each object class
    for i in range(len(data)):
        label = target.data[i]
        class_correct[label] += correct[i].item()
        class_total[label] += 1
        
for i in range(102):
    if class_total[i] > 0:
        print('Validation Accuracy of %5s %s %s: %2d%% (%2d/%2d)' % (
            model_pred_to_folder[i],'->',final[i], 100 * class_correct[i] / class_total[i],
            np.sum(class_correct[i]), np.sum(class_total[i])))
        
print('\nValidation Accuracy (Overall): %2d%% (%2d/%2d)' % (
    100. * np.sum(class_correct) / np.sum(class_total),
    np.sum(class_correct), np.sum(class_total)))

Sample Output

Validation Accuracy of     1 -> pink primrose: 60% ( 6/10)
Validation Accuracy of    10 -> globe thistle: 90% ( 9/10)
Validation Accuracy of   100 -> blanket flower: 80% ( 8/10)
Validation Accuracy of   101 -> trumpet creeper: 80% ( 8/10)
Validation Accuracy of   102 -> blackberry lily: 90% ( 9/10)
Validation Accuracy of    11 -> snapdragon: 80% ( 8/10)

(PS We can replace the Word Validation with Test)
Again Thanks a lot for the dataset !!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.