gabrielepicco / deep-learning-flower-identifier Goto Github PK
View Code? Open in Web Editor NEWDeep learning network to identify 102 different types of flowers
License: MIT License
Deep learning network to identify 102 different types of flowers
License: MIT License
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
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 :)
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 !!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.