fashion classification and detection using convolutional...

37
Fashion Classification and Detection Using Convolutional Neural Networks Prateek Srivastava & Archit Arora November 10, 2016

Upload: others

Post on 29-May-2020

15 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

FashionClassificationandDetectionUsingConvolutionalNeuralNetworks

Prateek Srivastava&Archit Arora

November10,2016

Page 2: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

FashionClassificationProblem

• Given an image, identify the apparel a particular person is wearing

Page 3: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Applications

• Targetedads

• Productrecommendations

• IdentificationofsuspectsthroughCCTVfootage

• Brandadoptiontrendforclothingcompanies

Page 4: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Challenges

• Intra-classvariation• Viewpointandlocationalvariation• Scalevariation• Backgroundclutter

Page 5: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Challenges

• Intra-classvariation• Viewpointandlocationalvariation• Scalevariation• Backgroundclutter

Page 6: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Challenges

• Intra-classvariation• Viewpointandlocationalvariation• Scalevariation• Backgroundclutter

Page 7: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Challenges

• Intra-classvariation• Viewpointandlocationalvariation• Scalevariation• Backgroundclutter

Page 8: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Overviewoffashionclassificationprocess

• Datacollection• Dataaugmentation• Learningfromdata• Imageclassification&objectdetection

Page 9: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Datacollection

• UsedScrapy tooltosearchandcrawlMacy’swebsite• Generatedalabelleddatasetofaround3500imagesbelongingtothesecategories

Jacket Long-dress Poloshirts Suit Short-dress

T-shirt Sweater Trousers Shoes Robe

Shirt Jeans Swimsuit Shorts

14 Fashion Categories

Page 10: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Dataaugmentation/preprocessing

• Implementedtoimproverobustnessoftheclassifier• Effectsintroducedtoaccountfordeviationsfromtrainingdataset:

1. Backgroundnoise(whitebackgroundconvertedtonoisybackground)2. Randomjitter(Randomjittercontrast:ApplyPCAtoallpixelsintraining

set,samplea”coloroffset”alongprincipalcomponentandthenaddoffsettoallpixels)

3. Rotation4. Contrastchange5. Croptotacklescalevariances6. Resizingtotackleresolutionvariances7. Imagenormalization

(subtractingthemeanfromrespectiveRGBchannels)

• scipy,scikit-imagewereusedtoaddtheaboveeffects

Page 11: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

HiddenLayer-1 HiddenLayer-2

OutputLayer

InputLayer(pixelsofeachimage)

Learningfromdata:Multi-layerperceptron

Page 12: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

HiddenLayer-1 HiddenLayer-2

OutputLayer

InputLayer(pixelsofeachimage)

w11

w12

w13

w14

Learningfromdata:Multi-layerperceptron

Page 13: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

w11

w12

w13

w14

HiddenLayer-1 HiddenLayer-2

OutputLayer

InputLayer

w11

w31

w21

Learningfromdata:Multi-layerperceptron

Non-linearactivationfunctiontoidentify

complexdatapatterns.Eg:f(x)=max(0,x)(ReLu)

Page 14: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

w11

w12

w13

w14

w11

w31

w21

w11

w12

w13

w14

HiddenLayer-1 HiddenLayer-2

OutputLayer

InputLayer

Learningfromdata:Multi-layerperceptron

Page 15: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

w11

w12

w13

w14

w11

w31

w21

w11

w12

w13

w14

HiddenLayer-1 HiddenLayer-2

OutputLayer

InputLayer

w11

w12

w13

w14

Learningfromdata:Multi-layerperceptron

Page 16: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

w11

w12

w13

w14

w11

w31

w21

w11

w12

w13

w14

w11

w12

w13

w14

HiddenLayer-1 HiddenLayer-2

OutputLayer

InputLayer

w11

w12

w13

w14

Learningfromdata:Multi-layerperceptron

Softmax functiontoassign

probabilitiestoclasses.

Page 17: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Learningfromdata:ConvolutionalNeuralNetworks(CNN)

[SlidestakenfromLec-7CS231NConvolutionalNeuralNetworksforComputerVision]

Imageinputasvolume

MainIssue:Multi-LayerPerceptrondoesnotscalewelltoimagedata.UseCNNs!

Page 18: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Learningfromdata:ConvolutionalNeuralNetworks(CNN)

Depthoffilteristhesamethedepthofinputvolume

[SlidestakenfromLec-7CS231NConvolutionalNeuralNetworksforComputerVision]

Page 19: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Learningfromdata:ConvolutionalNeuralNetworks(CNN)

[SlidestakenfromLec-7CS231NConvolutionalNeuralNetworksforComputerVision]

Evaluatesimagesimilaritywithfiltertemplate

Page 20: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Learningfromdata:ConvolutionalNeuralNetworks(CNN)

[SlidestakenfromLec-7CS231NConvolutionalNeuralNetworksforComputerVision]

Non-linearactivation

functionlikeReLu

Page 21: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Learningfromdata:ConvolutionalNeuralNetworks(CNN)

[SlidestakenfromLec-7CS231NConvolutionalNeuralNetworksforComputerVision]

Non-linearactivation

functionlikeReLu

Page 22: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Learningfromdata:ConvolutionalNeuralNetworks(CNN)

[SlidestakenfromLec-7CS231NConvolutionalNeuralNetworksforComputerVision]

Page 23: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

StepsinvolvedinTrainingData

• DefineLossfunctionforminimization:Cross-entropyorNegativeLikelihoodused

𝐿 𝒙, 𝒚,𝑾 =1𝑛))𝐼{,-./}

/∈3

log 𝑃(𝑌: = 𝑐|=

:.>

𝑥:) + 𝝀| 𝑾 |𝟐

• Usemini-batchSGDtominimizeloss• Initializeweights𝑾𝟎forallthelayers• Updaterule:

𝑾(𝒌G𝟏) = 𝑾(𝒌) − 𝒔𝒌(𝜵𝑾𝑳(𝑾))

Gradient(Difficulttocomputedirectly)

Page 24: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

GradientComputationsbasedonComputationalGraphs

2

1

-1

0.73𝟏

𝒑 = 𝒘𝟎𝒙𝟎

𝒒 = 𝒑+𝒘𝟏

𝒛 =𝟏

𝟏+ 𝒆R𝒒 =

𝟐

𝑓 𝑥T,𝑤T,𝑤> =1

1 + 𝑒R(WXYXGWZ)Gradientof (2,1,1)at

ForwardPropagation

Page 25: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

GradientComputationsbasedonComputationalGraphs

2

1

-1

0.196

0.196

0.196

0.392

0.196

𝒑 = 𝟐

𝒛 = 0.73𝒒 = 𝟏

𝒅𝒛𝒅𝒒 =

𝒅𝒛𝒅𝒘𝟏

=𝒅𝒛𝒅𝒒

𝒅𝒒𝒅𝒘𝟏

=

𝒅𝒛𝒅𝒑 =

𝒅𝒛𝒅𝒒

𝒅𝒒𝒅𝒑

𝒅𝒛𝒅𝒙𝟎

=𝒅𝒛𝒅𝒑

𝒅𝒑𝒅𝒙𝟎

𝒅𝒛𝒅𝒘𝟎

=𝒅𝒛𝒅𝒑

𝒅𝒑𝒅𝒘𝟎

𝑓 𝑥T,𝑤T,𝑤> =1

1 + 𝑒R(WXYXGWZ)Gradientof (2,1,1)at

MainIdea:Calculateglobalgradientsusingchainruleonlocalgradients

BackwardPropagation

Page 26: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

UsingPre-trainedmodels

• Inpractice,trainingCNNsfromscratchishardlyusedduetocomputationalconsiderations• Instead,pre-trainedmodelstrainedonotherdatasetareused• Mainidea:Lowlevelfeaturesarecommontoallimageclassificationproblems

• ForourprojectweusedVGG-16modeltrainedforImageNetclassificationchallengeon1000categories

Page 27: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

VGG-16Architecture

• Input: 224x224 size images with 3 channels1. Convolutional (224x224x64)2. Convolutional (224x224x64)Max Pool (112x112x64)3. Convolutional (112x112x128)4. Convolutional (112x112x128)Max Pool (56x56x128)5. Convolutional (56x56x256)6. Convolutional (56x56x256)7. Convolutional (56x56x256)Max Pool (28x28x256)8. Convolutional (28x28x512)9. Convolutional (28x28x512)10. Convolutional (28x28x512)Max Pool (14x14x512)

11. Convolutional (14x14x512)12. Convolutional (14x14x512)13. Convolutional (14x14x512)Max Pool (7x7x512)14. Fully Connected (1x1x4096)15. Fully Connected (1x1x4096)16. Fully Connected (1x1x1000) Soft-max (1x1x1000)

Reducesspatialdimensions

Page 28: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Implementation:ModifiedVGG-16

• Input: 224x224 size images with 3 channels1. Convolutional (224x224x64)2. Convolutional (224x224x64)Max Pool (112x112x64)3. Convolutional (112x112x128)4. Convolutional (112x112x128)Max Pool (56x56x128)5. Convolutional (56x56x256)6. Convolutional (56x56x256)7. Convolutional (56x56x256)Max Pool (28x28x256)8. Convolutional (28x28x512)9. Convolutional (28x28x512)10. Convolutional (28x28x512)Max Pool (14x14x512)

11. Convolutional (14x14x512)12. Convolutional (14x14x512)13. Convolutional (14x14x512)Max Pool (7x7x512)14. Fully Connected (1x1x4096)15. Fully Connected (1x1x4096)16. Fully Connected (1x1x1000) Soft-max (1x1x1000)

Treatthepreviouslayers(weights)asfixedandtunetheparametersonthelast3fullyconnectedlayers

Page 29: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Implementation:ModifiedVGG-16

• Input: 224x224 size images with 3 channels1. Convolutional (224x224x64)2. Convolutional (224x224x64)Max Pool (112x112x64)3. Convolutional (112x112x128)4. Convolutional (112x112x128)Max Pool (56x56x128)5. Convolutional (56x56x256)6. Convolutional (56x56x256)7. Convolutional (56x56x256)Max Pool (28x28x256)8. Convolutional (28x28x512)9. Convolutional (28x28x512)10. Convolutional (28x28x512)Max Pool (14x14x512)

11. Convolutional (14x14x512)12. Convolutional (14x14x512)13. Convolutional (14x14x512)Max Pool (7x7x512)14. Fully Connected (1x1x4096)15. Fully Connected (1x1x4096)16. Fully Connected (1x1x1000) Soft-max (1x1x1000)

ImplementedCNNarchitectureusingTheano(library)andLasagne(wrapper)withCUDAGPUonAWSEC2server

Page 30: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Cross-entropylossversusnumberofiterationsusingNesterov momentumupdaterule

ResultsusingMacy’sdata

• Initially,resultswereobservedusingthetrain-testsplitwithinMacy’s

data(withoutdataaugmentation)

• ~92%accuracywasachieved

Page 31: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

ResultsusingMacy’sdata

Page 32: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

TrainingData TestData

ResultsusingMacy’sdata

• Resultswereexceptionallybad(~20%accuracy)whenusingthesametrainingdatatopredictatestdataofreallifeexamplesfromGoogleImages• Hence,therewasaneedfordataaugmentation

Page 33: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Resultsfortestdataafterdataaugmentation

• Thetestdataconsistedofaround60imagesfromGoogleImages

comprisingofrealworldphotos

• ~71%accuracywasachieved

Cross-entropylossversusnumberofiterationsusingNesterov momentumupdaterule

Page 34: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Resultsfortestdataafterdataaugmentation

Page 35: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

NextSteps…

• Extendanalysistomultipleclothingobjectdetection• Approach:UseaslidingwindowapproachwithfastlinearclassifierstoidentifyregionsofinterestandapplyCNNs• DeterminespecificobjectlocationusingregressionheadwithaL2lossfunctioninsteadofclassificationheadwithcross-entropyloss

Page 36: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

THANKYOU

Page 37: Fashion Classification and Detection Using Convolutional ...neddimitrov.org/uploads/classes/201604CO/... · Fashion Classification and Detection Using Convolutional Neural Networks

Label Category

0 Jacket

1 T-Shirt

2 Shirt

3 Jeans

4 Long-dress

5 Shoes

6 Trousers

7 Polo-shirts

8 Robe

9 Short-dress

10 Shorts

11 Suit

12 Sweater

13 Swimsuit

ResultsusingMacy’sdata