Dog Breed Identification

Page 1

Dog Breed Identification

1,2,3,4 Department of computer science and engineering, Apex Institute of Technology Chandigarh University, Mohali,Punjab,India

Abstract - Dog Breed Identification has become essential to understand the conditions or climate in which dogs can survive. To identify dog breeds according to their physical features such as size, shape, and color, Dog Breed Identificationtechniqueshavebeenused.Wehaveconsidered a dataset of 120 dog breeds to identify a dog's breed. This methodbeginswithConvolutionalNeuralNetworks(CNNs)or transfer learning. This method is evaluated with evaluation metrics and accuracy. And to achieve the best evaluation, we have also made use of Hyperparameter Tuning. In the deployment phase, we connected our model with the web Framework using Flask

Key Words: Convolutional Neural Networks (CNNs), TensorFlow, GPU, Flask, Transfer Learning, MobilenetV2, Ngrok.

1.INTRODUCTION

Mostofushavesomelikingforanimalsandthemostliked animalofthemisDog[1].Dogsareknownfortheirloyalty, sweetness, and playfulness but on the contrary, some of them are dangerous too. We often encounter them in our daily routines, be it on the streets, in parks, or cafes. However, identifying the breed of a dog based on its appearancecanbechallenging,especiallyforthosewhoare not well-versed in the different breeds. So, our project is basedonidentifyingthebreedofdog,whichwillhelpdog loverstoknowwhichbreedofdogwillbesuitableforthe regionwheretheylive.Itwillbegoodforthemaswellasfor dogs too. Because many dogs are not able to habituate themselvesandmaydieatanearlyage.Thisprojectfocuses on developing an app that provides a simple, fast, and reliablewaytoidentifyadog’sbreedthroughImageanalysis andConvolutionalNeuralNetwork(CNN)architecture[2]. AnalyzingImagesusingdifferentcomputertechniqueswith predictive analysis that are being used in many different fields not only technology but agriculture too [3]. The applicationwillbeaccessiblethroughmodernwebbrowsers ondesktopandmobiledevices,makingiteasyforusersto accessitanywhere.

PunyanuchBorwarnginn,etal.[4]trainedthemodelwhich couldbetrainedonasmalldataset.Theytrainedtheirmodel with 3 different CNN techniques, namely MobilenetV2, InceptionV3,andNASNet.XiaoluZhang,etal.[5]createda cat detection model using deep learning techniques and deployitthroughamobileapplication.

***

The application will utilize machine learning algorithms, suchasTensorFlow,toanalyzethephotoanddeterminethe breed of the dog in real time. TensorFlow plays a very importantroleintheprojectasithelpstowritefastDeep learning code. It can run on a GPU (Graphics Processing Unit). GPUs are commonly used for deep learning model trainingandinference.Asthedatasetisveryhugeandthere aremanyimagesitwouldtakealotoftimetotrain,sowe willuseGPUwhichis30timesfasterthanCPUinprocessing.

2. LITERATURE SURVEY

Borwarnginn,etal.[4] proposedanapproachtodogbreed classification using transfer learning techniques. By leveraging pre-trained CNNs from large datasets such as ImageNet, the model was able to be trained with a small dataset.Theproposedmethodusesdeeplearningandimage augmentation to accurately identify dog breeds based on theirfaceimages.Itwasexperimentedwiththreedifferent CNNmodels,namelyMobilenetV2,InceptionV3,andNASNet. TheresultsshowthattheNASNetmodeltrainedonasetof rotatedimagesachievesthehighestaccuracyof89.92%.

Uma, et al. [2] focusedonfine-grainedclassificationofdog breedsandtheoutcomesofthesuggestedsystembasedona largenumberofbreeds.Whiletheresultsdemonstratethe potentialofCNNsforpredictingdogbreeds,furtherresearch isrequiredtoinvestigatetheirefficacy.However,itisworth noting that the training times for neural networks can be quite lengthy, limiting the number of iterations possible withinthescopeofthisstudy.

Kumar, et al. [6] proposedanapproachusingOpenCVand theVGG16model,whichwassuccessfulindetectinghuman and dog faces and determining the corresponding breed using a combination of CNN and ResNet101 architecture. Themodel'sperformanceexceededexpectations,achieving anaccuracyof81percentcomparedtojust13percentfora CNNmodelbuiltfromscratch.Theresultssuggestthatthis approachholdssignificantpromiseforfutureresearchinthe fieldofdogbreedclassification.

Zhang, et al. [5] primarily focused on creating a cat detection model using deep learning techniques and deployingitthrougha mobileapplication.Theapplication hasbeenprogrammedtorecognize14differenttypesofcats, achievinganaverageaccuracyrateof81.74%.Byoptimizing thedatasetandadjustingthehyperparameters,themodel

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056 Volume: 10 Issue: 05 | May 2023 www.irjet.net p-ISSN: 2395-0072 © 2023, IRJET | Impact Factor value: 8.226 | ISO 9001:2008 Certified Journal | Page1169
Arshdeep Singh Ghotra1, Harashleen Kour2, Anas Hasan3 and Akash Khan4

was able to significantly improve the accuracy to around 81.74%.

Manoj,etal.[7] proposedadeepneuralnetworkalgorithm for identifying cattle breeds using CNNs. In this proposed system,over150cattleimagedatasetswere collectedand preprocessed by converting them to a specific dimension andremovingnoise.TheSIFTmethodwasusedforfeature extraction, where it has been extracted for different body parts of the cattle. They then classified the cattle into 25 classesusingCNNandpredictedthecattlebreed.

Yadav, et al. [15] proposed a method for cattle size determinationusingstereopsis,whichallowsforthestudyof cowsintheirnaturalenvironmentwithoutdisturbingtheir routine activities. The authors utilized the Mask-RCNN convolutional neural network trained with the error backpropagationalgorithm. TheResNet-101 network was selected as the CNN backbone for Mask R-CNN, providing parallelcomputationandreducingforecasttime.

Vaidya S., et al. [19] discussedhowaddingmoretraining andtestdatacanenhancemodelaccuracyandovercomethe problemofoverfitting.Thisarticlehighlightstheimportance of data in deep learning and its impact on model performance.

Kumar, et al. [11] presentedanimagerecognitionsystem thatidentifiesthebreedofadogbyprocessingasingleinput image.Thesystemutilizedaconvolutionalneuralnetwork (CNN)and a pixel-wise scanning algorithm to identify the breed. This research showcases the potential of deep learninginanimalbreedidentification.

V.K, et al. [17] evaluatedvariousdeeplearningalgorithms forpredictingthebreedofadog.Theauthorscomparedthe outcomes of different algorithms based on evaluation metricssuchasaccuracy,precision,recall,andareaunder the curve (AUC). They also optimized one of the bestperformingalgorithmsforbreedprediction.Thisresearch demonstrates the effectiveness of deep learning in breed identificationandtheimportanceofalgorithmselectionfor optimalperformance.

3. PROPOSED METHODOLOGY

Todevelopadogbreedidentificationsystem,wehaveused the Convolutional Neural Network (CNN) and the Tensorflow MobileNetV2 architecture. We started by collecting a dataset of dog images having a total of 120 differentbreedsinthemandpreprocessedit.Then,weused the MobileNetV2 model as a feature extractor, extracting features from the images, and using those to train a CNN model.Duringthetraining,weexperimentedwithdifferent batchsizes,epochs,andhyperparameters,suchaslearning rate,dropout,andoptimizer.Aftertraining,weevaluatedthe model'sperformanceusingatestsetofimagesandfurther tunethehyperparametersbasedontheresults.Finally,the

trained model has been deployed on the web using Tensorflow's MobileNetV2 framework, Flask, and Ngrok frameworks.Thiswillallowtheuserstotakeapictureofa dog, and upload it in the web framework created and the model,whichwillbeworkingbehindthescenes,willhelpto predictthebreedofagivenpictureofthedog.

A bit more detail on how we have used CNN, Tensorflow MobileNetV2architecture,andFlaskwebframeworkfordog breedidentification:

1.DataCollectionandPreprocessing: Wehavecollecteda largedatasetofdogimages,withavarietyof120different breeds.ThisdatasethasbeentakenfromKaggle.Afterthe collectionofdata,weresizedtheimagestoaconsistentsize, normalizethecolorchannels,andsplitthedataintotraining, validation,andtestsets.

2. Feature Selection and Extraction: We have used the TensorFlow MobileNetV2 architecture to extract features from the images. This architecture is a pre-trained CNN modelthathasbeentrainedonmillionsofimages,including dogs. We have used this pre-trained model as a feature extractorandextractedthelastlayer'soutputasthefeature vector for each image. These features can then be used to traintheCNNmodel.

3. Model Training and Evaluation: We have trained the CNNmodelontheextractedfeaturesfromtheMobileNetV2 modeltoclassifydogbreeds.Themodelcanbetrainedusing various optimization algorithms, such as Sequential. Evaluatethemodel'sperformanceonaseparatetestsetof images.Metricssuchasaccuracy,precision,recall,andF1scorecanbeusedtomeasurethemodel'sperformance.

4.Model Deployment: Thetrainedmodelisbeingdeployed on the web using Tensorflow's MobileNetV2 framework. This will allow the users to take a picture of a dog, and upload it in the web framework created and the model, whichwillbeworkingbehindthescenes,willhelptopredict thebreedofagivenpictureofthedog.

Fig.1.Workflowoftheproposedsystem

4. EXPERIMENTAL RESULTS

A.Dataset:

Thesuccessofanymachinelearningprojectlargelydepends on the quality and size of the dataset. In this project, we aimedtoidentifydogbreedsfromtheirpictures.Toachieve this,wecollectedalargeanddiversedatasetfromKaggle,

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056 Volume: 10 Issue: 05 | May 2023 www.irjet.net p-ISSN: 2395-0072 © 2023, IRJET | Impact Factor value: 8.226 | ISO 9001:2008 Certified Journal | Page1170

which included over 10,222 unique images of dogs from morethan120differentbreeds.Theimagesweretakenfrom various angles and under different lighting conditions to makethemodelmorerobust.

B.Pre-processingtheimage:

When a user uploads an image, it is pre-processed before being fed into the TensorFlow model. First, the image is convertedintoatensor,whichisamultidimensionalarray withauniformdatatype.Wesetthemaximumsizeofthe image to 225 pixels, and the pixel values of the image are represented in the tensor as an array with values ranging from0to224.

To reduce the training time of the model, we batchify the images.Wehaveadatasetof10,222imagesofdogstaken fromdifferentanglesandunderdifferentlightingconditions. Theseimagesaredividedinto32batches,witheachbatch containing25imagesofdifferentdogs.

C.FeatureExtraction:

ConvolutionalNeuralNetworks(CNNs)areusedtotrainon large datasets. In this project, we use the MobileNetV2 framework, which has proven to be highly effective in accurately classifying dog breeds based on images in the training dataset. The MobileNetV2 architecture allows for faster processing times and efficient use of computing resources.InMobileNetV2thearemanyfeaturesthatgoon thosebreakdownsthe224X224sizeimageintosmallparts basedonthelayers.

Itconsistsofthefollowinglayerswhichareasfollow:

1. ConvolutionalLayers:

Inaconvolutionallayer,theinputimageisconvolvedwitha setoffilterstoproduceasetoffeaturemaps.Thefiltersare learned through backpropagation during the training process. The output of the convolutional layer can be computedasfollows:

In a depthwise divisible convolution, the traditional convolutionoperationissplitintotwoparts:adepth-wise convolutionthatappliesadistinctalgorithmtoeachinput channel and a pointwise convolution that uses a 1x1 convolutiontomergethedepthwiseconvolutionresults.The output of the depthwise separable convolution can be computedasfollows:

3. ActivationFunctions:

Activation functions are applied after each convolutional layertointroducenonlinearityintothenetworkandallowit to learn extensive characteristics. ReLU (Rectified Linear Unit), sigmoid, and tanh represent some of prevalent activationfunctions.Theoutcomeoftheactivationfunction canbecomputedasfollows:

4. FullyConnectedLayers:

Infullyconnectedlayer,eachneuronislinkedtoeveryother neuroninthelayerbelowitinacompletelyconnectedlayer. Thecompletelylinkedlayer'soutputmaybecalculatedas follows:

 Y{i,j,k}:Theoutputfeaturemapatlocation(i,j)and channelk.

 X{i,j,c}:Theinputimageatlocation(i,j)andchannel c

 W{u,v,c,k}:Theweightofthefilteratposition(u,v), channelc,andoutputchannelk

 bk:Thebiastermforchannelk

 sigma:Theactivationfunction

 m:Thesizeofthefilter

 C:Thenumberofinputchannels

2. DepthwiseSeparableConvolutions:

5.SoftMaxactivationfunction:

TheSoftMaxactivationfunctionisappliedtotheoutputof thefinallayertoconverttherawscoresintoprobabilitiesfor eachclass.Theclasswiththehighestprobabilityisselected asthepredicteddogbreed.

Fig.2MobileNetV2Architecture

D.EvaluationMetrics:

In the previous sections, we followed a series of steps to preprocesstheinputimagesandconvertthemintotensors, whicharenumericalrepresentationsthatcanbefedintothe deep learning model. Then, we created batches of these tensorstotrainthemodelonthedogbreeddataset.During

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056 Volume: 10 Issue: 05 | May 2023 www.irjet.net p-ISSN: 2395-0072 © 2023, IRJET | Impact Factor value: 8.226 | ISO 9001:2008 Certified Journal | Page1171

thetrainingprocess,themodellearnedtoextractrelevant featuresfromtheimagesandclassifythemintodifferentdog breeds.Aftertraining,weunbatchifiedthemodel'soutput tensors to obtain the predicted probabilities for each dog breed in the dataset. To perform testing, we provided the modelwithcustomimages(Fig.3.)thatwerepreprocessed andconvertedintotensorsinthesamewayasthetraining data.Themodelthengeneratedapredictionforeachimage, and we used these predictions to create a bar graph that shows the predictedprobabilitiesforeachdogbreed. The breedwiththehighestprobabilityistheonethatthemodel identifiedasthemostlikelymatchforthegiveninputimage.

WeusedtheevaluationparameterofAccuracytomeasure the performance of our dog breed classification model during training. As we selected 100 epochs to train the model,itwasimportanttomonitortheaccuracytoensure that the model was learning and improving over time. To helpwiththis,weusedcallbackfunctionsthatwouldstop the training process if the accuracy of the model didn't increase for a certain number of epochs, or if it remained constant for an extended period. This helped to save time andcomputationalresourcesbypreventingthemodelfrom continuingtotrainwhenitwasnolongermakingsignificant improvements.Thesecallbackfunctionswereausefultool forensuringthatourmodelwaslearningeffectivelyandnot wasting time on training that wouldn't lead to improved accuracy.Bymonitoringandadjustingthetrainingprocess inthisway,wewereabletoachieveahighlevelofaccuracy andcreatearobustmodelfordogbreedclassification.

Basedonourevaluation(Fig.4.),wefoundthatourmodel's testingaccuracyisbetterthanmostofthemodelspresented intheliterature.Thisislikelydueinparttoouruseofthe MobileNetV2architecture,whichisconsideredtobeoneof the best architectures for image classification tasks under theCNNframework.Comparedtootherarchitecturesand basicCNNmodels,MobileNetV2offersseveraladvantages.It isoptimizedformobiledevicesandhasasmallermemory footprint,whilestillmaintaininghighaccuracy.Additionally, itusesdepthwiseseparableconvolutions,whichreducethe number of parameters in the model and speed up computation.It'simportanttonotethattestingaccuracyisa more reliable indicator of a model's performance on new, unseen data than training accuracy. By evaluating our model'sperformanceonaseparatetestingdataset,wecan bemoreconfidentthatitwillgeneralizewelltonewdata.

Overall, we believe that our use of the MobileNetV2 architecture was a key factor in achieving high testing accuracy, and we are excited to continue exploring the performanceofourmodelonnewdatasetsandindifferent applications.

5. CONCLUSIONS

The primary objective of our research was to develop a model that could accurately classify different dog breeds basedontheirphysicalcharacteristicssuchassize,shape, and color. To achieve this, we employed a Convolutional NeuralNetwork(CNN)withtheMobileNetV2architecture fortrainingourmodel.Wetrainedourmodelonadataset consisting of 120 different dog breeds, and the model achieved an impressive accuracy of 99.89% during the

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056 Volume: 10 Issue: 05 | May 2023 www.irjet.net p-ISSN: 2395-0072 © 2023, IRJET | Impact Factor value: 8.226 | ISO 9001:2008 Certified Journal | Page1172
Fig.3.TrainedDataimageofarandomdog. Table.1.Comparisonbetweenothermodelaccuracy.

trainingphase.However,totrulyevaluatetheeffectiveness of our model, we tested it on a separate set of data. Our testingresultsshowedthatourmodelwasabletoaccurately classifydogbreedswithahighdegreeofaccuracy.Wefound that the MobileNetV2 architecture was one of the best choicesforourclassificationtask,asitreducedthenumber of parameters in our model while still maintaining high accuracy.Thishelpedtoimprovetheefficiencyofourmodel and allowed it to evaluate the breed of dogs quickly. To further validate our findings, we compared our model's accuracy with that of a basic CNN, and we found that the MobileNetV2 architecture outperformed the basic CNN in terms of accuracy. This highlights the effectiveness of transferlearning,whereweusedpre-trainedweightsfroma larger dataset to fine-tune our model on our specific classificationtask.Overall,ourresultssuggestthattheuseof MobileNetV2architecturefortrainingourCNNmodelwas successfulinaccuratelyclassifyingdogbreedsbasedontheir physicalcharacteristics.

Infuturework,wecanincreasetheaccuracyofthemodelby providing more data to the model. We can also apply the followingtechniquestoprepareawebapplicationormobile applicationswhichanymobileusercaneasilyuseandtakea dogpictureandfindthebreedofthedog.

REFERENCES

[1] Prasanth Vaidya S., et al. “A Novel Dog Breed Identification using Convolutional Neural Network". PrimeraScientificEngineering2.1(2023):16-21

[2] K.Uma, et al." Dog BreedClassifierUsingNon-Linear ConvolutionalNeuralNetwork."SchoolofInformation Technology, Vellore Institute of Technology, Vellore, India.YMER||ISSN:0044-0477

[3] Kenneth Lai, et al. “Dog Identification using Soft Biometrics and Neural Networks”. Biometric TechnologiesLaboratory,DepartmentofECE,University of Calgary, Canada. International Joint Conference on NeuralNetworks.Budapest,Hungary.

[4] Borwarnginn, et al(2021). Knowing your dog breed: Identifyingadogbreedwithdeeplearning.International JournalofAutomationandComputing,18,45-54.

[5] Xiaolu Zhang, et al. “A Mobile Application for Cat Detection and Breed Recognition Based on Deep Learning”.UniversityofMelbourne,Australia

[6] SantoshKumar,etal."ClassificationandIdentificationof DogBreedUsing.

[7] CNN." ICDSMLA 2020: Proceedings of the 2nd International Conference on Data Science, Machine LearningandApplications.SpringerSingapore,2022.

[8] Lee, et al. "Analysis of Transfer Learning Effect for Automatic Dog Breed Classification." Journal of BroadcastEngineering27.1(2022):133-145.

[9] Agarwal, et al. "Optimized Transfer Learning for Dog Breed

[10] Mondal, Ayan, et al. "A Convolutional Neural NetworkBased Approach for Automatic Dog Breed Classification Using Modified-Xception Model." Electronic Systems and Intelligent Computing: ProceedingsofESIC2021.Singapore:SpringerNature Singapore,2022.61-70.

[11] Kumar,etal."Dogbreedclassifierforfacialrecognition using convolutional neural networks." 2020 3rd International Conference on Intelligent Sustainable Systems(ICISS).IEEE,2020.

[12] AvijitDasgupta,etal."BreedClassificationofDogsUsing FusionofTextandImageFeatures".Thispaperpresents a novel approach to dog breed classification using a fusionoftextandimagefeatures.

[13] SangxiaHuang,etal."Multi-LabelImageClassification with Deep Learning". This paper explores the use of deeplearningmodelsformulti-labelimageclassification tasks,suchasidentifyingmultipledogbreedsinasingle image.

[14] Prachi Thakur, et al. "A Comparative Study of Image ClassificationAlgorithms on DogsDataset".Thispaper provides a comparative analysis of various image classificationalgorithms,includingSVM,decisiontrees, andk-nearestneighbors,forclassifyingdogbreeds.

[15] BharatYadav,etal."EnhancedDogBreedClassification using Transfer Learning and Fine-tuning". This paper explores the use of transfer learning and fine-tuning techniques for improving the accuracy of dog breed classification.

[16] J. Wang, et al. "Deep Learning for Dog Breed Identification and Fine-grained Classification". This paperpresentsadeep-learningapproachtodogbreed identification and fine-grained classification using a combinationofCNNsanddeepbeliefnetworks(DBNs).

[17] V. K. Singh, et al. “A Comparative Analysis of Deep Learning Techniques for Dog Breed Classification.” International Journal of Computer Science and InformationSecurity,vol.17,no.1,2019.

[18] M. Z. Khan, et al. “A Framework for Automatic Dog BreedIdentificationusingTransferLearningwithPretrained Convolutional Neural Network.” Journal of Ambient Intelligence and Humanized Computing, vol. 10,no.7,pp.2963-2975,2019.

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056 Volume: 10 Issue: 05 | May 2023 www.irjet.net p-ISSN: 2395-0072 © 2023, IRJET | Impact Factor value: 8.226 | ISO 9001:2008 Certified Journal | Page1173

[19] S.Zou,etal.“ALightweightandAccurateApproachto DogBreedClassification.”JournalofComputerScience andTechnology,vol.36,no.2,pp.324-335,2021.

[20] P. Singh, et al. “A Deep Learning Based Approach for Dog Breed Identification and Classification.” Procedia ComputerScience,vol.167,pp.1241-1252,2020.

[21] M.He,etal.“DogBreedClassificationusingMulti-Task LearningandConvolutionalNeuralNetworks.”Journal ofAppliedMathematicsandComputerScience,vol.30, no.1,pp.131-143,2020.

[22] Y.Zhang,etal.“Fine-GrainedDogBreedClassification using Deep Convolutional Neural Networks.” In Proceedingsofthe201813thInternationalConference onComputerScience&Education,pp.157-160,2018.

[23] J. Jia, et al. “Dog Breed Classification Based on MultiLevelFeatureFusion.”InProceedingsofthe20203rd International Conference on Advances in Computer Technology,InformationScienceandCommunications, pp.307-311,2020.

[24] S. Jain, et al. “Dog Breed Classification using MultiConvolutionalNeuralNetworks.”InProceedingsofthe 2021 5th International Conference on Information Management,pp.57-61,2021.

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056 Volume: 10 Issue: 05 | May 2023 www.irjet.net p-ISSN: 2395-0072 © 2023, IRJET | Impact Factor value: 8.226 | ISO 9001:2008 Certified Journal | Page1174

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.