🚀 大規模食品圖像分割基準
本項目構建了一個新的食品圖像數據集FoodSeg103,包含7118張圖像。同時提出了一種多模態預訓練方法ReLeM,為分割模型賦予豐富的語義食品知識。項目使用多種語義分割方法進行評估,為細粒度食品圖像理解提供了基準。
🚀 快速開始
若要快速上手本項目,可參考以下步驟:
- 安裝:請參考 get_started.md 進行安裝。
- 數據集下載:從 鏈接 下載文件,並將數據解壓到
./data
文件夾(./data/FoodSeg103/
),密碼為:LARCdataset9947。
- 訓練與測試:參考後續 “Train & Test” 章節的腳本進行模型的訓練和測試。
✨ 主要特性
- 新數據集:構建了包含7118張圖像的食品圖像數據集FoodSeg103,並標註了104個食材類別,每張圖像平均有6個食材標籤和像素級掩碼。
- 多模態預訓練方法:提出了名為ReLeM的多模態預訓練方法,為分割模型賦予豐富的語義食品知識。
- 多方法評估:使用三種流行的語義分割方法(基於膨脹卷積、基於特徵金字塔和基於視覺Transformer)作為基線,並在新數據集上進行評估。
📦 安裝指南
請參考 get_started.md 進行安裝。
💻 使用示例
基礎用法
以下是訓練腳本的基礎用法:
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 --master_port=${PORT:-300} tools/train.py --config [config] --work-dir [work-dir] --launcher pytorch
示例:
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 --master_port=${PORT:-300} tools/train.py --config configs/foodnet/SETR_Naive_768x768_80k_base_RM.py --work-dir checkpoints/SETR_Naive_ReLeM --launcher pytorch
高級用法
以下是測試腳本的使用示例,用於在訓練好的模型上進行評估:
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 --master_port=${PORT:-999} tools/test.py [config] [weights] --launcher pytorch --eval mIoU
示例:
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 --master_port=${PORT:-999} tools/test.py checkpoints/SETR_Naive_ReLeM/SETR_Naive_768x768_80k_base_RM.py checkpoints/SETR_Naive_ReLeM/iter_80000.pth --launcher pytorch --eval mIoU
📚 詳細文檔
數據集
請從 鏈接 下載文件,並將數據解壓到 ./data
文件夾(./data/FoodSeg103/
),密碼為:LARCdataset9947。
排行榜
請參考 排行榜 瞭解更多信息。
基準和模型庫
編碼器 |
解碼器 |
裁剪尺寸 |
批量大小 |
mIoU |
mAcc |
鏈接 |
R-50 |
FPN |
512x1024 |
8 |
27.8 |
38.2 |
模型+配置 |
ReLeM-R-50 |
FPN |
512x1024 |
8 |
29.1 |
39.8 |
模型+配置 |
R-50 |
CCNet |
512x1024 |
8 |
35.5 |
45.3 |
模型+配置 |
ReLeM-R-50 |
CCNet |
512x1024 |
8 |
36.8 |
47.4 |
模型+配置 |
PVT-S |
FPN |
512x1024 |
8 |
31.3 |
43.0 |
模型+配置 |
ReLeM-PVT-S |
FPN |
512x1024 |
8 |
32.0 |
44.1 |
模型+配置 |
ViT-16/B |
Naive |
768x768 |
4 |
41.3 |
52.7 |
模型+配置 |
ReLeM-ViT-16/B |
Naive |
768x768 |
4 |
43.9 |
57.0 |
模型+配置 |
ViT-16/B |
PUP |
768x768 |
4 |
38.5 |
49.1 |
模型+配置 |
ReLeM-ViT-16/B |
PUP |
768x768 |
4 |
42.5 |
53.9 |
模型+配置 |
ViT-16/B |
MLA |
768x768 |
4 |
45.1 |
57.4 |
模型+配置 |
ReLeM-ViT-16/B |
MLA |
768x768 |
4 |
43.3 |
55.9 |
模型+配置 |
ViT-16/L |
MLA |
768x768 |
4 |
44.5 |
56.6 |
模型+配置 |
Swin-S |
UperNet |
512x1024 |
8 |
41.6 |
53.6 |
模型+配置 |
Swin-B |
UperNet |
512x1024 |
8 |
41.2 |
53.9 |
模型+配置 |
ReLeM
我們基於 im2recipe 的實現進行了小修改,在 Recipe1M+ 數據集(移除了FoodSeg103的測試圖像)上訓練了基於食譜信息的模型。由於數據量巨大(>35G),我可能會稍後上傳lmdb文件。
使用8張Tesla-V100顯卡訓練一個ReLeM ViT-Base模型大約需要2 - 3周時間,因此強烈建議使用我預訓練好的模型(鏈接)。
🔧 技術細節
訓練策略
- PVT模型:使用逐步學習策略進行訓練,因為發現該策略可以獲得更高的性能。
- 其他基線模型:採用默認設置進行訓練。
- ReLeM模型:由於時間限制,使用Recipe1M訓練ReLeM-PVT-S,而其他ReLeM模型使用Recipe1M+進行訓練。
📄 許可證
本項目採用 Apache 2.0許可證 發佈。
引用
如果您在研究中發現本項目有用,請考慮引用:
@inproceedings{wu2021foodseg,
title={A Large-Scale Benchmark for Food Image Segmentation},
author={Wu, Xiongwei and Fu, Xin and Liu, Ying and Lim, Ee-Peng and Hoi, Steven CH and Sun, Qianru},
booktitle={Proceedings of ACM international conference on Multimedia},
year={2021}
}
其他問題
如果在使用軟件過程中遇到其他問題,可以查看原始的mmsegmentation文檔(鏈接)獲取更多詳細信息。
致謝
本項目中的分割軟件主要基於 segmentation 進行擴展開發。