Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Lecture materials at the University of Tokyo Sc...

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →
Maxwell
October 25, 2021

Lecture materials at the University of Tokyo School of Medicine

Materials for the lecture held on October 25, 2021, at the University of Tokyo

Updated: Jul.2022

Maxwell

October 25, 2021

Transcript

22 slides
  1. 平松 雄司 東京大学 未来ビジョン研究センター(アクサ生命保険から出向) Senior Data Scientist,Kaggle Master, A.I.A.J 

    保険数理 / データ分析 ・アクチュアリー(収益管理 / プロジェクション) ・データサイエンティスト(予測モデル / 最適化 / 教育) 現在は,アクサ生命 から 東京大学 へ研究員として出向 主に医療データの分析・研究  本やブログ記事の執筆 Kaggle への参加
  2.  2019 / 10 / 09 発売後,ロングセラー Kindle 版も同時発売 ¥

    3,608 (税込み) 技術評論社の EPUB/PDF でも発売中 https://gihyo.jp/dp/ebook/2019/978-4-297-10844-1  データ分析コンペティションプラットフォームである Kaggle における数々の分析手法・テクニックを紹介  平松は 2 章と 7 章の一部 を担当 2 章:評価指標の最適化,リーク 7 章:アンサンブル,スタッキング  Kaggle に限らず,実務でも活かせる内容になっています https://amzn.to/2lDkWlf
  3.  誰でも参加でき世界中の分析者と競争することができる  どの分野の企業や組織でもコンペを開催可能  提示されたビジネス課題を解決するモデルを作成し, 決められた条件下で予測結果の精度を競うのが一般的 (中にはデータからビジネス課題を提案したりするコンペも)  上位者にはメダルや賞金が与えられるが

    メダルの獲得数・種類によって付与される称号が人気 (近年は学生のうちに Master/GrandMaster を目指す方も)  プログラミング言語は基本的には Python か R Kaggle とは データ分析のスキルを競い合うオープンプラットフォーム https://www.kaggle.com/competitions
  4. タスクとデータ PAS 染色された腎生検組織標本から 糸球体を segmentation するタスク Whole Slide Image 一枚あたり数GBの巨大画像

    train : 15 WSIs public : 5 WSIs private : 10 WSIs 評価指標は Dice Coefficient(F1) typically 100 - 350 um glomeruli WSI
  5. Public LB Private LB  コンペ開催期間中に目安となる順位  test data の

    10 - 20 % くらいを使用して スコア計算されることが多い  実際の順位はコンペ終了後にこちらで決定  public で未使用の test data で評価されるのが基本  過学習によるモデルの誤評価を防ぐための措置 Public LB / Private LB
  6. WSI をどのようにあつかうか? Training Inference U-Net 等のセグメンテーションモデルに入力可能なサイズ (e.g. 256 x 256)にパッチ化して学習

    パッチ化の仕方は - ダウンスケールする - 信号がない部分は取り除く - ランダムに切り出す - 幾分かオーバーラップさせて座標順に切り出す など,色々なやり方が考えられるが, これらの工夫は Augmentation の検討をしているのに近い パッチの端部分はパターンの突然欠損により, マスクの推論がうまくいかない場合が多いため(Edge effect) 例えば,一定割合でオーバーラップさせて推論する オーバーラップ部はオーバーラップした回数で重み調整を行い, 必要に応じたアップスケールも行った上で WSI に変換する overlapping WSI Predicted Mask WSI extract a patch
  7. Predicted Mask WSI 1st place solution https://github.com/tikutikutiku/kaggle-hubmap https://www.kaggle.com/c/hubmap-kidney-segmentation/discussion/238198 1024 1024

    320 320 WSI Extract patches Decoder Block Down-scaled patches SE-ResNeXt 101 backbone Balanced patch sampling Encoder Block classification head segmentation head Hypercolumns Deep Supervision 1 2 3 Predicted patch Total Segmentation Loss: Segmentation Loss + Deep Supervision Loss Segmentation Loss: BCE + Lovasz-hinge Deep Supervision Loss: 0.1 * (BCE + Lovasz-hinge) only for non-empty mask Classification: BCE 1 2 3 1 2 Copyright 2021 Maxwell_110  1024 x 1024 パッチを 512 ずつ overlap しつつ切り出し 320 x 320 にダウンスケール  生検患者の ID をもとに 4 Fold CV  学習時には,マスクの占める面積に応じたバランスがとれる ようにパッチをサンプリング  SE-ResNeXt-101 backbone U-Net + Classification Head + Deep Supervision (Lee et al., 2014) + Hypercolumns (Hariharan et al., 2014)  推論されたパッチの中心部だけを使用して WSI に復元 (マスク有無の分類出力を利用して計算コストを低減) Augmentations: HorizontalFlip RandomRotate, ShiftScaleRotate CoarseDropout GaussianBlur, GaussNoise HueSaturation RandomBrightnessContrast
  8. Decoder Block Encoder Block https://www.kaggle.com/c/hubmap-kidney-segmentation/discussion/238013 https://github.com/Shujun-He/Hubmap-3rd-place-solution/ Copyright 2021 Maxwell_110 3rd

    place solution WSI Extract patches 1024 1024 512 512  1024 x 1024 パッチを順に切り出し 512 x 512 にダウンスケール  5 KFold CV  ResNeXt 50 / 101 backbone U-Net (2 model ensemble) + Hypercolumns (Hariharan et al., 2014)  様々な Data Augmentations  推論されたパッチの中心部だけを使用して WSI に復元 ResNeXt 50/101 backbone Down-scaled patches Hypercolumns segmentation head Predicted patch Predicted Mask WSI Augmentations: HorizontalFlip, VerticalFlip, RandomRotate, ShiftScaleRotate ElasticTransform GaussianBlur, GaussNoise OpticalDistortion, GridDistortion, AffineTransform HueSaturation, CLAHE RandomBrightnessContrast Coutout Loss: BCE Augmentation 1st place solution と共通しているのは - Augmentations - Hypercolumns - パッチの中心部を抜き出して推論 多くの segmentation タスクで 普遍的に通用する可能性が高い (パッチ中心部抜き出しは WSI の場合)
  9. 最近ローンチされた医療系コンペ 神経細胞のインスタンスセグメンテーション https://www.kaggle.com/c/sartorius-cell-instance-segmentation/overview 開催元: ザルトリウス(独の医薬品製造機器メーカー) 評価指標: 複数 IOU 閾値別に求めた precision

    の平均 開催期間: Oct. 14. 2021 - Dec. 31. 2021(UTC; 2.5 months) データ: Train ~600 images,Test ~240 images 提出タイプ: Kaggle Kernel 上で推論のみコードで実行(<= GPU 9h) Raw image (PNG format) Masks Credit to: https://www.kaggle.com/ihelon/cell-segmentation-run-length-decoding 一枚の中に多数のマスクが存在 704 pixcels 520 pixcels
  10. Submission on kernel environment • Approximately 8 hours running (5

    folds, 3 TTA, 2 models) • Good correlation between local CV and public LB (Alghough there are deviations..., maybe due to the d48 image) • Local CV: 0.9429 Public LB: 0.927 Private LB: 0.947 Preprocessing / Augmentation • Naive normalization; divided by 255 • 5 folds; 3 WSI for each fold • Augmentations (p=0.5) - Horizontal/Vertical Flip (p=0.5) - RandomRotate90 (p=0.5) - Rotate (-40/+40, reflect101, p=0.5) - ShiftScaleRotate (scale: -0.2/0.1, p=0.5) - OneOf (p=0.5) RandomBrightnessContrast (B: 0.5, C: 0.1) HueSaturationValue (H: +-20, S: +-100, V: +-80) - One of (p=0.5) Cutout (holes: 100, size: 1/64, white RGB) GaussianNoise - One of (p=0.5) ElasticTransform GridDistortion (steps: 5, limit: 0.3) OpticalDistortion (distort: 0.5, shift: 0.0) Cutting out patches • Remove black/white pathes for training - White (R:217, G:213, B:217) color information was used to add noise and fill the edges of the images in augmentation. - Not removing black/white pathes for validation images • Different scale patches for ensemble Group A (for final submission): Size = 352, Down scale = 4 Size = 512, Down scale = 2 Group B: Size = 352, Down scale = 4 Size = 640, Down scale = 2 • In addition to cutting out the normal patches, also cutting out patches shifted by a quarter of the patch size. Psuedo - Labeled 5 Mask-WSIs (Unfortunately PL was useless for private score...) Remove black / white patches for training Decoder Block Encoder Block 15 WSIs (Whole Slide Images) Predicted 5/10 Mask-WSIs for Public/Private 1 2 U-Net type model Back bone: EfficientNet B3 (ImageNet pretrained) 3 4 5 Resources: TITAN RTX, 2080Ti x 2, 1080Ti x 2 Copyright 2021 Maxwell_110 Size: 352 x 352 Down scale: 4 + Size: 640 x 640 Down scale: 2 HuBMAP - Hacking the Kidney Model Pipeline 17 th place 6 1 Training • BCE + Adam(1stLR: 7.5e-4, 2ndLR: 2.5e-4) • BS: 8 (size 640), 12 (size 512), 16 (size 352) • Patience: ES = 10, RLRoP = 3 • Training with train images only at first, and then with train + public(psuedo) images • Alternate training with psuedo labels Step 1: Train with Group A, and predict pseudo labels for public images Step 2: Next, Train with Group B and pseudo labels, and predict pseudo labels Step 3: Repeat the aboves sufficiently Step 4: Submit predictions trained with Group A (+ pseudo labeld public images) 3 2 Size: 352 x 352 Down scale: 4 + Size: 512 x 512 Down scale: 2 B A Prediction + Tiling predicted patches • TTA: Raw, HorizontalFlip, VerticalFlip • Overlapping by 1/16 image size for tiling • Naive averaging for ensemble (folds and models) • Threshold optimization with train images (th: 0.40) 6 5 4

More Decks by Maxwell

Other Decks in Science