본문 바로가기
전공 기본기를 다져요/내맘대로 딥러닝

내맘대로 딥러닝 (1) - Image Classification

by 포숑은 맛있어 2022. 8. 3.
반응형

내 지식 테스트겸 각 주제에 대해 주절주절 적어보려고 한다.

 

"Image Classification."

 

지식

1. ImageNet Challenge와 고전 네트워크

먼저 고전 네트워크 한번 봐주면 좋겠다.

물론 지금 ResNet 말고는 딱히 쓸 일이 없겠지만.

https://greeksharifa.github.io/computer%20vision/2021/10/24/ImageNet-CNN-models/ 이 글을 참고하는게 좋겠다.

 

2. SOTA 모델까지 쫓아오기

워낙 빨리 바뀌어서 트렌드 쫓아가기 어렵긴 하다.

대충 내 기억으로는 처음 입사했을 즈음에는 RegNet 이런거 나왔던것같은데. Neural Architecture Search는 비효율적이니까 논외...

어느새 image backbone은 EfficientNet 원툴이 되었다가, 2020년도 후반부터 ViT때문에 transformer가 한동안 설치더니, conv와 transformer를 같이 쓴다고 하질 않나, 그러다 갑자기 EfficientNet V2가 압살해버리고, 또 요즘 foundation model들이 나오는 느낌.

https://paperswithcode.com/sota/image-classification-on-imagenet 

 

Papers with Code - ImageNet Benchmark (Image Classification)

The current state-of-the-art on ImageNet is CoCa (finetuned). See a full comparison of 681 papers with code.

paperswithcode.com

 

코드

kaggle 보는것도 좋겠지만 내가 캐글은 잘 안봐서...

 

1. CIFAR-10 벤치마크

  • 코드가 간단하고 다양한 모델들로 구성
  • 그래서 pytorch 기본 코드를 공부하기 좋아보인다. train, model 등등..
  • 약 2년 전 까지 업데이트가 되어있음
  • 다들 여기서 가져다 쓰는건지, fork나 star가 엄청 많다. 나도 뭐때문인지는 기억 안나는데 이걸 써본 기억이 있다 ㅋㅋㅋ
  • DLA는 뭔지 모르겠고, EfficientNet V1, RegNet까지는 구현이 되어있다.

https://github.com/kuangliu/pytorch-cifar

 

GitHub - kuangliu/pytorch-cifar: 95.47% on CIFAR10 with PyTorch

95.47% on CIFAR10 with PyTorch. Contribute to kuangliu/pytorch-cifar development by creating an account on GitHub.

github.com

대략 이정도?

 

2. 성능이 높아야할 경우?

챌린지 할때 필요하겠지. 일단 pretraining 필수.

요즘 SOTA라면 foundation model, vision+language representation learning 계열이다.

 

하지만 이건 코드가 복잡하여 단시간 구현에 적합하지 않을 것.

(쓰고싶은 데이터에 finetuning 하나 하려는데 건드려야 하는 코드가 많을수도..?!)

(데이터가 large-scale이라면 특히나 더?! GPU 캐파가...)

 

성능 영끌이라면 기존에 알려진 방법으로는

  • 다양한 augmentation 및 Loss function (mixup 이런거)
  • 앙상블
  • class imbalance가 있다면 가중치를 다르게 주거나
  • 기타 등등..? 이지만 사실 그냥 제일 좋은 복잡한 모델 하나 받는게 짱임

그리고 그 SOTA 모델의 각 모듈에서도 최신 모델이 아닌 경우에는 그거 하나 바꿔주면 성능이 더 오를 것 같기도 하다.

예를 들면 vision+language 모델인데 vision encoder를 그냥 vanilla ViT를 쓰는 경우에는 아무래도 최신 모델을 쓰면 더 좋겠지.

 

 

 

아니면 이런 것도 있다. 

  • 불과 이틀 전에도 업데이트가 되었으며 온갖 SOTA 모델들이 구현되어있음.
  • 모델 뿐만 아니라 augmentation 기법들도 많이 있고, label smoothing 등의 loss도 구현이 되어있어서 공부하기 편할 듯?
  • 이거 한번 봐줘야겠다.

https://github.com/rwightman/pytorch-image-models

 

GitHub - rwightman/pytorch-image-models: PyTorch image models, scripts, pretrained weights -- ResNet, ResNeXT, EfficientNet, Eff

PyTorch image models, scripts, pretrained weights -- ResNet, ResNeXT, EfficientNet, EfficientNetV2, NFNet, Vision Transformer, MixNet, MobileNet-V3/V2, RegNet, DPN, CSPNet, and more - GitHub - rwig...

github.com

 

 

3. 적당히 빠르게 좋은 모델?

그냥 적당히 유명하고 좋은 모델이면서, pretrained model을 지원하면서, 규모가 크지 않은 코드가 좋은 것 같다.

 

예를들면 action recognition을 위해 slowfast 하나 심심해서 돌려보겠다고 페이스북 공식코드 쓰면 겁나 복잡하다.

차라리 Kinetics-{400|600|700} 중 하나 이상 pretraining 한거 지원해주는 비공식 코드가 훨씬 낫다.

 

그리고 너무 최신코드면 저자가 논문 붙을때까지 코드를 안 올릴수도 있고, pretrained 지원을 안하거나 코드가 지저분할수 있다. 검증도 안되었고..

 

 

image classification에서 적당한 코드를 좀 찾아보자.
이미 써봤거나 나중에 써볼 예정인 것들

 

 

EfficientNet 

pip으로 설치 가능, 겁나 간단하다. 나중에 써봐야지

https://github.com/lukemelas/EfficientNet-PyTorch

 

GitHub - lukemelas/EfficientNet-PyTorch: A PyTorch implementation of EfficientNet and EfficientNetV2 (coming soon!)

A PyTorch implementation of EfficientNet and EfficientNetV2 (coming soon!) - GitHub - lukemelas/EfficientNet-PyTorch: A PyTorch implementation of EfficientNet and EfficientNetV2 (coming soon!)

github.com

이 코드도 간단해서 좋다. 유명한 MAE.

한번 돌려봤다.

https://github.com/pengzhiliang/MAE-pytorch

 

GitHub - pengzhiliang/MAE-pytorch: Unofficial PyTorch implementation of Masked Autoencoders Are Scalable Vision Learners

Unofficial PyTorch implementation of Masked Autoencoders Are Scalable Vision Learners - GitHub - pengzhiliang/MAE-pytorch: Unofficial PyTorch implementation of Masked Autoencoders Are Scalable Visi...

github.com

각종 태스크 SOTA list 보면 심심할때 한번씩 보이는 Swin V2. 이것도 간단.

https://github.com/ChristophReich1996/Swin-Transformer-V2

 

GitHub - ChristophReich1996/Swin-Transformer-V2: PyTorch reimplementation of the paper "Swin Transformer V2: Scaling Up Capacity

PyTorch reimplementation of the paper "Swin Transformer V2: Scaling Up Capacity and Resolution" [CVPR 2022]. - GitHub - ChristophReich1996/Swin-Transformer-V2: PyTorch reimplementation of...

github.com

 

대충 뭐 빨리 돌려야할때 잘 써야지

반응형

댓글