liu123456-shi/wuhu648648-MetaFood

7

stars

7

commits

Jupyter Notebook

primary language

Jun 7, 2025

updated

README

Repository Overview

This repository houses the code implementation for the technical report of the 3D Reconstruction From Monocular Multi-Food Images Challenge at the CVPR 2025 MetaFood Workshop.

3D 模型

Get Started

SAM Installation

pip install -r ./SAM/requirements.txt

Hunyuan3Dv2 Installation

pip install -r ./Hunyuan3D-2/requirements.txt

Usage

Data Preparation

.
└── food_mask
    ├── 1-bagel_cream_cheese
    ├── 2-breaded_fish_lemon_broccoli
    ├── 3-burger_hot_dog
    ├── 4-cheesecake_strawberry_raspberry
    ├── 5-energy_bar_cheddar_cheese_banana
    ├── 6-grilled_salmon_broccoli
    ├── 7-pasta_garlic_bread
    ├── 8-pbj_carrot_stick_apple_celery
    ├── 9-pizza_chicken_wing
    ├── 10-quesadilla_guacamole_salsa
    ├── 11-roast_chicken_leg_biscuit
    ├── 12-sandwich_cookie
    ├── 13-steak_mashed_potatoes
    └── 14-toast_sausage_fried_egg

Plate (Reference Object) Segmentation

python ./SAM/plate_sam.py

Food Segmentation (Per Food Item)

Modify the api_key in food_sam.py before running:

python ./SAM/food_sam.py

Output Data Format After Execution:

.
└── food_mask
    ├── 1-bagel_cream_cheese
    │   ├── 1.jpeg
    │   ├── 1_boxes_filt.txt    # Bounding box for the plate
    │   ├── bagel.jpg
    │   ├── bagel.txt           # Bounding box for bagel
    │   ├── bagel_cropped.jpg   # Segmented bagel image
    │   ├── cream_cheese.jpg
    │   ├── cream_cheese.txt    # Bounding box for cream cheese
    │   ├── cream_cheese_cropped.jpg  # Segmented cream cheese image
    │   └── plate.jpg
    ├── 2-breaded_fish_lemon_broccoli
    ├── 3-burger_hot_dog
    ├── 4-cheesecake_strawberry_raspberry
    ├── 5-energy_bar_cheddar_cheese_banana
    ├── 6-grilled_salmon_broccoli
    ├── 7-pasta_garlic_bread
    ├── 8-pbj_carrot_stick_apple_celery
    ├── 9-pizza_chicken_wing
    ├── 10-quesadilla_guacamole_salsa
    ├── 11-roast_chicken_leg_biscuit
    ├── 12-sandwich_cookie
    ├── 13-steak_mashed_potatoes
    └── 14-toast_sausage_fried_egg

3D Reconstruction

python mask_big.py
python ./Hunyuan3D-2/food.py

Scale Estimation

python scale_estimation.py
  • Adjust real_plate for the actual width of the reference plate (e.g., a physical plate’s width).
  • Tune the perspective scaling factor r as needed.

Volume and Chamfer Distance Metrics

3D 模型

Object IndexPredicted volumeGround truthError percentageChamfer distance
1293.65280.7112.945.796618
28.1330.2622.1310.137541
377.4893.2515.776.59741
415.868.847.029.079356
512.7614.351.592.981458
6363.56435.2471.6810.368625
713.93222.66208.7329.412099
896.0794.31.778.543460
924.9836.1711.194.372186
105.635.470.161.160205
1126.0257.7331.719.177924
1235.2186.9451.7312.646923
1392.01141.6749.669.913942
1488.38130.6742.2913.828343
15203.42828.23624.8129.171016
1652.7281.4828.767.391703
17204.89262.958.015.810387
184.1585.2881.1315.484578
19197.11131.5665.558.866644
2012.214.62.412.712560
2117.9589.371.3521.676434
2258.2147.9910.223.871832
2325.7177.1551.4413.725036
24211.74122.9388.819.740972
254.745.5440.8410.343567
26140.16134.415.7513.049587
2793.39106.5713.182.600901
2884.1198.43114.3315.395517
2927.1853.5826.424.625002
30171.43147.7423.695.350468
31157.43246.4889.0517.255887
3287.41117.129.696.394715
338.7918.189.397.279437
3414.5838.8824.39.452481

Segmentation Metric Calculation

We evaluate food segmentation performance (beyond competition metrics like volume and Chamfer Distance) using manually annotated bounding boxes as ground truth (GT). GT data structure:

.
└── food_mask_GT
    ├── 1-bagel_cream_cheese
    ├── 2-breaded_fish_lemon_broccoli
    ├── 3-burger_hot_dog
    ├── 4-cheesecake_strawberry_raspberry
    ├── 5-energy_bar_cheddar_cheese_banana
    ├── 6-grilled_salmon_broccoli
    ├── 7-pasta_garlic_bread
    ├── 8-pbj_carrot_stick_apple_celery
    ├── 9-pizza_chicken_wing
    ├── 10-quesadilla_guacamole_salsa
    ├── 11-roast_chicken_leg_biscuit
    ├── 12-sandwich_cookie
    ├── 13-steak_mashed_potatoes
    └── 14-toast_sausage_fried_egg

Calculate IOU for segmentation:

python IOU.py

Segmentation IOU Results

分割效果

Object IndexFood ItemIOU
1bagel0.986
2cream_cheese0.926
3breaded_fish0.943
4lemon0.945
5broccoli0.973
6burger0.968
7hot_dog0.330
8cheesecake0.970
9strawberry0.970
10raspberry0.970
11energy_bar0.980
12cheddar_cheese0.955
13banana0.903
14grilled_salmon0.975
15pasta0.646
16garlic_bread0.989
17pb&j0.958
18carrot_stick0.818
19apple0.967
20celery0.945
21pizza0.589
22chicken_wing0.978
23quesadilla0.954
24guacamole0.979
25salsa0.473
26roast_chicken_leg0.970
27biscuit0.948
28sandwich0.949
29cookie0.298
30steak0.969
31mashed_potatoes0.395
32toast0.967
33sausage0.922
34fried_egg0.969

🤗Acknowledgement

This work is built on many amazing research works and open-source projects, thanks a lot to all the authors for sharing!

Contributors

liu123456-shi

7 commits

liu123456-shi/wuhu648648-MetaFood

7

stars

7

commits

Jupyter Notebook

primary language

Jun 7, 2025

updated

README

Repository Overview

This repository houses the code implementation for the technical report of the 3D Reconstruction From Monocular Multi-Food Images Challenge at the CVPR 2025 MetaFood Workshop.

3D 模型

Get Started

SAM Installation

pip install -r ./SAM/requirements.txt

Hunyuan3Dv2 Installation

pip install -r ./Hunyuan3D-2/requirements.txt

Usage

Data Preparation

.
└── food_mask
    ├── 1-bagel_cream_cheese
    ├── 2-breaded_fish_lemon_broccoli
    ├── 3-burger_hot_dog
    ├── 4-cheesecake_strawberry_raspberry
    ├── 5-energy_bar_cheddar_cheese_banana
    ├── 6-grilled_salmon_broccoli
    ├── 7-pasta_garlic_bread
    ├── 8-pbj_carrot_stick_apple_celery
    ├── 9-pizza_chicken_wing
    ├── 10-quesadilla_guacamole_salsa
    ├── 11-roast_chicken_leg_biscuit
    ├── 12-sandwich_cookie
    ├── 13-steak_mashed_potatoes
    └── 14-toast_sausage_fried_egg

Plate (Reference Object) Segmentation

python ./SAM/plate_sam.py

Food Segmentation (Per Food Item)

Modify the api_key in food_sam.py before running:

python ./SAM/food_sam.py

Output Data Format After Execution:

.
└── food_mask
    ├── 1-bagel_cream_cheese
    │   ├── 1.jpeg
    │   ├── 1_boxes_filt.txt    # Bounding box for the plate
    │   ├── bagel.jpg
    │   ├── bagel.txt           # Bounding box for bagel
    │   ├── bagel_cropped.jpg   # Segmented bagel image
    │   ├── cream_cheese.jpg
    │   ├── cream_cheese.txt    # Bounding box for cream cheese
    │   ├── cream_cheese_cropped.jpg  # Segmented cream cheese image
    │   └── plate.jpg
    ├── 2-breaded_fish_lemon_broccoli
    ├── 3-burger_hot_dog
    ├── 4-cheesecake_strawberry_raspberry
    ├── 5-energy_bar_cheddar_cheese_banana
    ├── 6-grilled_salmon_broccoli
    ├── 7-pasta_garlic_bread
    ├── 8-pbj_carrot_stick_apple_celery
    ├── 9-pizza_chicken_wing
    ├── 10-quesadilla_guacamole_salsa
    ├── 11-roast_chicken_leg_biscuit
    ├── 12-sandwich_cookie
    ├── 13-steak_mashed_potatoes
    └── 14-toast_sausage_fried_egg

3D Reconstruction

python mask_big.py
python ./Hunyuan3D-2/food.py

Scale Estimation

python scale_estimation.py
  • Adjust real_plate for the actual width of the reference plate (e.g., a physical plate’s width).
  • Tune the perspective scaling factor r as needed.

Volume and Chamfer Distance Metrics

3D 模型

Object IndexPredicted volumeGround truthError percentageChamfer distance
1293.65280.7112.945.796618
28.1330.2622.1310.137541
377.4893.2515.776.59741
415.868.847.029.079356
512.7614.351.592.981458
6363.56435.2471.6810.368625
713.93222.66208.7329.412099
896.0794.31.778.543460
924.9836.1711.194.372186
105.635.470.161.160205
1126.0257.7331.719.177924
1235.2186.9451.7312.646923
1392.01141.6749.669.913942
1488.38130.6742.2913.828343
15203.42828.23624.8129.171016
1652.7281.4828.767.391703
17204.89262.958.015.810387
184.1585.2881.1315.484578
19197.11131.5665.558.866644
2012.214.62.412.712560
2117.9589.371.3521.676434
2258.2147.9910.223.871832
2325.7177.1551.4413.725036
24211.74122.9388.819.740972
254.745.5440.8410.343567
26140.16134.415.7513.049587
2793.39106.5713.182.600901
2884.1198.43114.3315.395517
2927.1853.5826.424.625002
30171.43147.7423.695.350468
31157.43246.4889.0517.255887
3287.41117.129.696.394715
338.7918.189.397.279437
3414.5838.8824.39.452481

Segmentation Metric Calculation

We evaluate food segmentation performance (beyond competition metrics like volume and Chamfer Distance) using manually annotated bounding boxes as ground truth (GT). GT data structure:

.
└── food_mask_GT
    ├── 1-bagel_cream_cheese
    ├── 2-breaded_fish_lemon_broccoli
    ├── 3-burger_hot_dog
    ├── 4-cheesecake_strawberry_raspberry
    ├── 5-energy_bar_cheddar_cheese_banana
    ├── 6-grilled_salmon_broccoli
    ├── 7-pasta_garlic_bread
    ├── 8-pbj_carrot_stick_apple_celery
    ├── 9-pizza_chicken_wing
    ├── 10-quesadilla_guacamole_salsa
    ├── 11-roast_chicken_leg_biscuit
    ├── 12-sandwich_cookie
    ├── 13-steak_mashed_potatoes
    └── 14-toast_sausage_fried_egg

Calculate IOU for segmentation:

python IOU.py

Segmentation IOU Results

分割效果

Object IndexFood ItemIOU
1bagel0.986
2cream_cheese0.926
3breaded_fish0.943
4lemon0.945
5broccoli0.973
6burger0.968
7hot_dog0.330
8cheesecake0.970
9strawberry0.970
10raspberry0.970
11energy_bar0.980
12cheddar_cheese0.955
13banana0.903
14grilled_salmon0.975
15pasta0.646
16garlic_bread0.989
17pb&j0.958
18carrot_stick0.818
19apple0.967
20celery0.945
21pizza0.589
22chicken_wing0.978
23quesadilla0.954
24guacamole0.979
25salsa0.473
26roast_chicken_leg0.970
27biscuit0.948
28sandwich0.949
29cookie0.298
30steak0.969
31mashed_potatoes0.395
32toast0.967
33sausage0.922
34fried_egg0.969

🤗Acknowledgement

This work is built on many amazing research works and open-source projects, thanks a lot to all the authors for sharing!

Contributors

liu123456-shi

7 commits

Languages

Jupyter Notebook

92.4%

Python

7.2%