Giter Club home page Giter Club logo

Comments (6)

hyoseok1223 avatar hyoseok1223 commented on August 12, 2024 3

TTA

현재 mmsegmentation baseline에서 제공되는 TTA는 img_ratio를 바꾸는 것입니다. multi_scale augmentation과 같은 효과를 보기 위해 사용하는 것인지 궁금해 찾아봤는데 명확하지 않고, 실제 사용시 img_ratio를 변경해서 TTA를 하는 것과 img_scale을 변경해 TTA를 하는 것의 시간차이가 엄청 많이 났습니다. ( 물론 사이즈 자체가 달라서일 수 있지만, 그러기에는 너무 큰 차이가 났습니다.)

  • img ratio변화시 inference time : 약 600s
  • img scale 변화시 inference time : 약 2500s

img_ratio를 기준으로 tta를 적용했을 때 기존의 적용하지 않았을 때와 큰 차이도 나지 않아 추론해보건데 무척 simple한 resizing이 일어나는 것 같습니다. 그래서 별로 도움이 안되나..? 싶기도 합니다. interpolation등이 별로라서,,?

img_scale을 기준으로 tta를 해본 것도 확인해본 결과 실제로 정말 다른 경향성을 보였습니다. 따라서 TTA를 쓰신다면 img_scale변경하시는 것을 추천드립니다.(기존의 augtest에서 img_ratio주석 처리하시고 img_scale추가해주시면 됩니다.)

if args.aug_test:
        # hard code index 
        # cfg.data.test.pipeline[1].img_ratios = [
        #     # 0.5, 
        #     1.0,  1.5 , 2.0
        #     # , 1.75
        # ]
        cfg.data.test.pipeline[1].img_scale = [(1024, 1024),(512,512),(1333,800)]
        cfg.data.test.pipeline[1].flip = True

달라진 경향성을 몇가지 샘플로 확인하면 아래와 같습니다. ( 좌 : not TTA , 우 : TTA )
image
image

이렇게 작은 객체에 대해서 더 잘 예측할 뿐아니라 2번째 샘플처럼 특이 케이스에 대해서도 더 깔끔하고 일종의 앙상블된 효과가 보이는 것을 확인할 수 있습니다.

from level2-semantic-segmentation-level2-cv-17.

hyoseok1223 avatar hyoseok1223 commented on August 12, 2024 1

저는 mmsegmentation에서 기본으로 제공하는 augmentation 중에 Resizemultiscale이었나, 그게 있었던 것 같아서 해당 augmentation을 사용하려고 했습니다.

from level2-semantic-segmentation-level2-cv-17.

baekkr95 avatar baekkr95 commented on August 12, 2024 1
  • torch(smp)에서 이미지 사이즈를 다양하게 입력하는 코드를 작성해봤고, 현재 실험 중 입니다.
  • transform.py의 get_train_transform 함수 안에 해당 코드를 넣었습니다.
  • 밑의 주석 친 2줄은 multi scale을 시도해봤지만 사이즈 관련 에러가 발생한 코드여서 무시하셔도 좋습니다.
transform = []
i = random.randint(0,2)
resize_list = [512, 1024, 768]
transform.append(A.Resize(resize_list[i], resize_list[i]))

# transform.append(A.RandomScale(0.5, p=1.0))
# transform.append(A.OneOf([A.Resize(512, 512), A.Resize(1024, 1024), A.Resize(768, 768), A.Resize(384, 384)], p=1.0))

#37 crop을 주는게 좋겠다는 의견을 보고, resize를 하기보단 RandomResizedCrop(512, 512)를 하는게 더 좋아보여서 위의 방식은 사용하지 않기로 했습니다. 또한 사이즈를 (512, 512)로 줘도 일부분만 crop한 뒤에 다시 512 사이즈로 변환하기 때문에 다양한 크기의 이미지 사이즈를 학습하는 효과도 있는 것 같습니다.

from level2-semantic-segmentation-level2-cv-17.

baekkr95 avatar baekkr95 commented on August 12, 2024

resize multiple scale은 A.Oneof에 A.resize 여러개 넣는 식으로 만들면 될까요?

from level2-semantic-segmentation-level2-cv-17.

baekkr95 avatar baekkr95 commented on August 12, 2024
  • torch(smp)에서 이미지 사이즈를 다양하게 입력하는 코드를 작성해봤고, 현재 실험 중 입니다.
  • transform.py의 get_train_transform 함수 안에 해당 코드를 넣었습니다.
  • 밑의 주석 친 2줄은 multi scale을 시도해봤지만 사이즈 관련 에러가 발생한 코드여서 무시하셔도 좋습니다.
transform = []
i = random.randint(0,2)
resize_list = [512, 1024, 768]
transform.append(A.Resize(resize_list[i], resize_list[i]))

# transform.append(A.RandomScale(0.5, p=1.0))
# transform.append(A.OneOf([A.Resize(512, 512), A.Resize(1024, 1024), A.Resize(768, 768), A.Resize(384, 384)], p=1.0))

from level2-semantic-segmentation-level2-cv-17.

hyoseok1223 avatar hyoseok1223 commented on August 12, 2024

작은 객체를 더 잘 맞추도록 학습하는 것이 mIoU관점에서 좋은 학습 방향이 아닌 것 같다는 생각이 듭니다.

  • 작은 객체들을 더 잘 맞추더라도 저희가 얻을 수 있는 mIoU의 향상은 매우 적습니다.
  • 반면, 개수가 적은 (클래스 개수가) 객체들 (battery, clothing) 등을 잘 맞추게 될 경우 비약적인 mIoU향상을 얻을 수 있습니다.

따라서, 성능향상을 위해서 학습 방향에 있어 small object에 집중하는 것은 좋지 않아보입니다. 이에 따라 이슈는 닫아두겠습니다.

  • 추가적으로 위에 comment들과 관련해서 RandomCrop( mmseg 내장 -> segmentatoin mask 포함 정도 설정 가능)을 통해 384로 학습시킨 결과 성능에 큰 차이가 존재하지 않으면서도 빠르게 학습이 되게 할 수 있었고, #37 에서도 언급했듯 이미지의 배경의 대부분이 다른 쓰레기인 경우나 쓰레기가 배경에 녹아들어있는(매트리스) 경우에도 좀 더 잘 잡을 수 있었던 것 같습니다.
dict(type='RandomCrop',crop_size=(384,384),cat_max_ratio=0.7),

활용해보시는 것도 좋아보입니다.

사용 전 사용 후 비교

  • 성능: 거의 유사합니다.( 오히려 조금 올라간 것 같기도 합니다)

  • 0.68~0.69 사이

  • 속도 : 1epoch당 시간이 1.5~2배정도 빨라졌습니다.

  • 실험들을 속도를 확인하기 위해 돌린 결과가 존재하지는 않지만, swin L upernet 기준으로 기존의 swin L을 그대로 사용하면서도 1epoch(valid하는데까지) 9분 이내의 시간이 소요됩니다. 이전에 선아님께서 cuda error를 위해 channel수를 낮추고 등등의 작업을 거치시고 1epoch에 14분 정도 걸리셨다는 것을 생각하면 유의미한 결과로 보입니다.

from level2-semantic-segmentation-level2-cv-17.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.