Skip to content

SIslamMun/Birds

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

Bird Species Classification from an Image Using VGG-16 Network

this is confidential project so i just provide some function

paper

Presentation

Library

tensorflow
keras
numpy
matplotlib
sklearn
opencv-python

Description

In this poject, the main objective is to classify Bangladeshi birds according to their own species using several machine learning algorithms through transfer learning. The dataset for this classification is one that I collected manually and consists only of bird species that are found in Bangladesh. This was done because there is no collection of local bird data in Bangladesh. We used the VGG-16 network as our model to extract the features from bird images. In order to perform the classification, we used several Algorithms. However, compared to other classification methods such as Random Forest and K-Nearest Neighbor (KNN), Support Vector Machine (SVM) gave us the maximum accuracy of 89%.

Import library

from os import listdir
from pickle import dump
from keras.applications.vgg16 import VGG16
from keras.preprocessing.image import load_img
from keras.preprocessing.image import img_to_array
from keras.applications.vgg16 import preprocess_input
from keras.models import Model

Feature extraction using VGG16

# extract features from each photo in the directory
def extract_features(directory):
	# load the model
	model = VGG16()
	# re-structure the model
	model.layers.pop()
	model = Model(inputs=model.inputs, outputs=model.layers[-1].output)
	# summarize
	print(model.summary())
	# extract features from each photo
	features = dict()
	for name in listdir(directory):
		# load an image from file
		filename = directory + '/' + name
		image = load_img(filename, target_size=(224, 224))
		# convert the image pixels to a numpy array
		image = img_to_array(image)
		# reshape data for the model
		image = image.reshape((1, image.shape[0], image.shape[1], image.shape[2]))
		# prepare the image for the VGG model
		image = preprocess_input(image)
		# get features
		feature = model.predict(image, verbose=0)
		# get image id
		image_id = name.split('.')[0]
		# store feature
		features[image_id] = feature
		print('>%s' % name)
	return features

train and test data selection

  

from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=.4,
                                                    random_state=0)

training model

  
import scikitplot as skplt

from sklearn.model_selection import cross_val_score
from sklearn import svm
clf = svm.SVC(probability=True)

#Train the model using the training sets
clf.fit(X_train, y_train)

#Predict the response for test dataset
y_pred = clf.predict(X_test)
#Import scikit-learn metrics module for accuracy calculation
from sklearn import metrics

# Model Accuracy: how often is the classifier correct?
print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
y_probas =clf.predict_proba(X_test)
import matplotlib.pyplot as plt
import scikitplot as skplt
skplt.metrics.plot_precision_recall_curve(y_test, y_probas)
plt.show()

License

A product of Shazzadul Islam

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published