CoolFace
Modelpublic

openfoodfacts/nutrition-extractor

sourceHugging Facecc-by-nc-sa-4.0updated 1y agoView on Hugging Face
18likes221downloads
Model Card

nutrition-extractor

This model is a fine-tuned version of microsoft/layoutlmv3-large on the openfoodfacts/nutrient-detection-layout dataset. It allows to automatically extract nutrition values from images of nutrition tables.

It achieves the following results on the evaluation set:

  • Loss: 0.0534
  • Precision: 0.9545
  • Recall: 0.9647
  • F1: 0.9596
  • Accuracy: 0.9917

Model description

This model can extract nutrient values from photos of food packaging containing nutrition information. This was developped as part of the Nutrisight project.

For more information about the project, please refer to the nutrisight directory in the openfoodfacts-ai GitHub repository.

As any model using the LayoutLM architecture, this model expects as input:

  • the image
  • the tokens (string) on the images
  • the 2D coordinates of each token

The tokens and their 2D positions is provided by an OCR model. This model was trained using OCR results coming from Google Cloud Vision.

An ONNX export of the model can be found in the onnx directory.

Intended uses & limitations

This model is only intended to be used on images of products where a nutrition table can be found.

Training and evaluation data

The training and evaluation data can be found on the dataset page.

Training procedure

Training hyperparameters

The following hyperparameters were used during training:

  • learning_rate: 1e-05
  • trainbatchsize: 4
  • evalbatchsize: 4
  • seed: 42
  • gradientaccumulationsteps: 8
  • totaltrainbatch_size: 32
  • optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
  • lrschedulertype: linear
  • training_steps: 3000
  • mixedprecisiontraining: Native AMP

Training results

Training LossEpochStepValidation LossPrecisionRecallF1Accuracy
1.98520.1664151.15000.00.00.00.8101
1.02440.3329300.83420.050.00740.01290.8123
0.78260.4993450.67950.07890.11380.09320.8479
0.67670.6657600.59630.11930.16440.13830.8578
0.60310.8322750.54060.16710.22480.19170.8691
0.57560.9986900.49350.22910.31120.26390.8778
0.52151.16501050.43020.32670.39480.35750.8905
0.47821.33151200.37820.39390.46540.42670.9020
0.42081.49791350.34050.40270.50440.44780.9081
0.35321.66441500.29300.49600.58200.53560.9252
0.34581.83081650.26580.51550.60330.55600.9301
0.3021.99721800.23210.61120.70090.65300.9474
0.26552.16371950.20930.64710.72640.68450.9520
0.25982.33012100.19510.70130.75570.72750.9570
0.23642.49652250.17940.70910.77430.74020.9590
0.22182.66302400.16760.72160.79330.75580.9621
0.2062.82942550.15720.74360.81100.77580.9650
0.20532.99582700.15800.73810.81140.77300.9640
0.18763.16232850.14060.77380.83090.80130.9687
0.16023.32873000.14200.77140.82770.79860.9671
0.17063.49513150.13230.79330.83790.81500.9691
0.15853.66163300.13130.80600.85510.82980.9700
0.15743.82803450.12670.81290.86390.83760.9717
0.153.99453600.11570.83360.87460.85360.9754
0.11924.16093750.11200.83480.87090.85250.9741
0.13134.32733900.11300.83950.87920.85890.9745
0.11794.49384050.10930.83700.88710.86130.9755
0.13274.66024200.11020.84000.88530.86210.9746
0.13234.82664350.09970.86110.89870.87950.9782
0.12544.99314500.09490.84990.89690.87280.9775
0.09995.15954650.08470.86580.89920.88220.9797
0.10175.32594800.08030.87470.91080.89240.9810
0.0915.49244950.07960.87840.90570.89180.9806
0.09795.65885100.09430.86070.89500.87750.9773
0.10245.82525250.08040.87100.90620.88820.9805
0.09525.99175400.07870.88450.91780.90080.9816
0.07426.15815550.07760.89180.91500.90330.9823
0.07646.32455700.07210.90280.91870.91070.9837
0.08136.49105850.06640.90650.92290.91460.9844
0.07916.65746000.06420.90260.92520.91380.9848
0.07926.82396150.06730.89640.92480.91040.9841
0.0786.99036300.06930.89380.92240.90790.9833
0.06787.15676450.06720.90820.93270.92030.9852
0.06857.32326600.06550.89260.92240.90730.9840
0.05557.48966750.06150.91560.92710.92130.9856
0.077.65606900.05870.91730.93730.92720.9868
0.0657.82257050.05580.92050.94050.93040.9875
0.05997.98897200.05790.92530.94330.93420.9878
0.05718.15537350.05930.91480.93310.92390.9866
0.05638.32187500.06050.91520.93220.92360.9863
0.06028.48827650.05810.92520.93080.92800.9863
0.05828.65467800.05810.92060.93730.92890.9872
0.05148.82117950.05570.92450.93820.93130.9873
0.04678.98758100.05200.92910.94980.93940.9883
0.04359.15408250.05260.92290.94470.93370.9880
0.05319.32048400.05020.92490.94430.93450.9884
0.05029.48688550.05450.91710.94520.93090.9874
0.03779.65338700.06180.90770.93680.92210.9851
0.04169.81978850.05490.92670.93920.93290.9881
0.0449.98619000.05290.93660.94750.94200.9884
0.038310.15269150.04900.93320.94750.94030.9889
0.045410.31909300.05070.92640.94710.93660.9885
0.041610.48549450.04670.93640.94980.94300.9891
0.040310.65199600.04990.93140.94570.93850.9886
0.035410.81839750.05230.92580.94520.93540.9883
0.033810.98479900.05210.92140.94240.93180.9880
0.034711.151210050.05390.92350.94750.93540.9880
0.036411.317610200.05600.91940.94800.93350.9871
0.036311.484010350.05090.92860.94800.93820.9889
0.030811.650510500.04980.93890.94840.94360.9893
0.03211.816910650.04910.93640.94430.94030.9891
0.033111.983410800.04550.93730.94430.94080.9892
0.030112.149810950.04860.93590.94890.94230.9892
0.030812.316211100.05130.93250.95030.94130.9891
0.025312.482711250.05100.92960.95030.93980.9892
0.030112.649111400.05330.93080.94890.93970.9886
0.032812.815511550.05490.92870.94430.93640.9885
0.029812.982011700.05040.94020.94980.94500.9895
0.025613.148411850.05150.93540.94190.93870.9888
0.031313.314812000.04830.94180.95450.94810.9905
0.02213.481312150.04630.93610.95310.94450.9899
0.024513.647712300.04940.93680.94940.94300.9893
0.025113.814112450.04930.94040.95310.94670.9898
0.025913.980612600.05110.93860.95220.94540.9895
0.0314.147012750.05350.93440.94570.94000.9889
0.019214.313512900.04910.94280.94940.94610.9899
0.026714.479913050.04900.94570.95450.95010.9901
0.024114.646313200.05060.94350.95400.94870.9899
0.021114.812813350.05100.94440.95400.94920.9903
0.017114.979213500.04990.94050.95450.94740.9898
0.022615.145613650.05110.93660.95400.94520.9894
0.02415.312113800.04840.94450.95590.95010.9899
0.01815.478513950.04820.94690.95170.94930.9903
0.019115.644914100.04910.94420.95120.94770.9899
0.020315.811414250.04510.95100.95540.95320.9912
0.019815.977814400.04470.94970.95490.95230.9911
0.016716.144214550.04440.94870.95400.95140.9909
0.017816.310714700.05130.93860.95120.94490.9892
0.02416.477114850.05020.94300.95360.94830.9899
0.020616.643615000.04590.94830.95450.95140.9908
0.018816.810015150.04690.94740.95400.95070.9906
0.01616.976415300.04630.94680.95820.95240.9906
0.016117.142915450.04550.95160.95960.95560.9911
0.013517.309315600.04750.95240.95730.95480.9909
0.014817.475715750.04790.94400.95450.94920.9905
0.017317.642215900.04550.95390.96050.95720.9915
0.017317.808616050.04560.94750.95540.95140.9913
0.018517.975016200.04610.94980.95770.95370.9908
0.015318.141516350.04720.94910.96050.95480.9911
0.014818.307916500.04460.95070.95870.95470.9913
0.013618.474316650.04410.94860.96010.95430.9914
0.018518.640816800.04780.95280.95730.95510.9915
0.014718.807216950.04930.95150.96520.95830.9912
0.015618.973617100.05090.94400.95450.94920.9903
0.011319.140117250.04600.95590.95730.95660.9911
0.01419.306517400.04930.94390.95260.94820.9905
0.014719.473017550.04980.94760.95680.95220.9906
0.012619.639417700.04930.94740.95310.95020.9906
0.016719.805817850.04910.94630.95770.95200.9904
0.012619.972318000.04740.94920.95400.95160.9908
0.010720.138718150.04620.95240.95770.95510.9914
0.011520.305118300.04810.95040.96140.95590.9911
0.012820.471618450.04860.94750.95630.95190.9907
0.011320.638018600.04910.94770.95910.95340.9910
0.011920.804418750.05140.94940.95030.94990.9901
0.012220.970918900.04800.94810.95910.95360.9911
0.012321.137319050.04770.94670.95770.95220.9909
0.011621.303719200.04860.94850.95820.95330.9910
0.010821.470219350.04880.94420.95820.95110.9905
0.011521.636619500.04720.94980.95870.95420.9913
0.008321.803119650.04760.94900.95960.95430.9911
0.009421.969519800.04750.94820.96050.95430.9909
0.011822.135919950.04920.94490.95540.95010.9904
0.0122.302420100.04860.94920.95540.95230.9909
0.011422.468820250.04970.95020.95770.95400.9910
0.009122.635220400.04990.95030.95820.95420.9910
0.007722.801720550.05020.95130.96140.95630.9911
0.0122.968120700.05130.95440.96280.95860.9913
0.008723.134520850.04850.95000.96100.95540.9912
0.007323.301021000.04850.95570.96280.95930.9917
0.008323.467421150.04850.95350.96100.95720.9913
0.011723.633821300.04790.95570.96240.95900.9916
0.009523.800321450.05080.94980.95870.95420.9911
0.00923.966721600.05130.94920.96280.95600.9910
0.007724.133121750.05040.95530.96280.95910.9915
0.008724.299621900.05000.95210.96100.95650.9913
0.006824.466022050.05060.95390.96100.95740.9913
0.009424.632522200.05000.95070.95910.95490.9913
0.008824.798922350.04860.95080.95960.95520.9914
0.008924.965322500.05070.95080.96100.95590.9911
0.006325.131822650.04790.95610.96100.95850.9917
0.005825.298222800.05060.95260.96190.95720.9911
0.010225.464622950.04990.95260.96240.95750.9912
0.007925.631123100.05430.94690.96140.95410.9905
0.00925.797523250.04980.95260.96190.95720.9915
0.006825.963923400.05110.95090.96190.95640.9911
0.00726.130423550.04920.95270.96330.95800.9914
0.008626.296823700.05160.95000.96100.95540.9913
0.007826.463223850.05030.95040.96100.95570.9914
0.006726.629724000.05140.95270.96280.95770.9915
0.005926.796124150.05040.95490.96280.95880.9919
0.008926.962624300.05200.95170.96050.95610.9916
0.005927.129024450.05120.95220.96240.95730.9917
0.007327.295424600.05260.95300.96100.95700.9916
0.006527.461924750.05300.95270.96280.95770.9916
0.006427.628324900.05150.95350.96100.95720.9917
0.007227.794725050.05420.94820.96100.95460.9907
0.006627.961225200.05370.94910.96100.95500.9909
0.00628.127625350.05180.95310.96280.95790.9915
0.007428.294025500.05230.95210.96100.95650.9914
0.006828.460525650.05340.94950.96140.95550.9913
0.005528.626925800.05210.95480.96190.95840.9917
0.005628.793325950.05260.95220.96140.95680.9913
0.006628.959826100.05270.95220.96190.95700.9913
0.005329.126226250.05330.95310.96280.95790.9913
0.006329.292626400.05200.95300.96100.95700.9913
0.005929.459126550.05330.95040.96050.95540.9910
0.005929.625526700.05320.95260.96190.95720.9912
0.006229.792026850.05160.95350.96240.95790.9917
0.006429.958427000.05150.95220.96240.95730.9915
0.005530.124827150.05130.95490.96330.95910.9917
0.006430.291327300.05240.95400.96280.95840.9916
0.005530.457727450.05300.95310.96330.95820.9915
0.006530.624127600.05280.95360.96420.95890.9917
0.006830.790627750.05300.95180.96330.95750.9916
0.004730.957027900.05450.95320.96470.95890.9916
0.005131.123428050.05340.95450.96470.95960.9917
0.004431.289928200.05320.95310.96330.95820.9914
0.006831.456328350.05320.95270.96330.95800.9913
0.004531.622728500.05310.95450.96380.95910.9915
0.004731.789228650.05300.95400.96330.95860.9916
0.007531.955628800.05330.95490.96380.95930.9916
0.005532.122128950.05250.95530.96380.95950.9917
0.00632.288529100.05230.95530.96380.95950.9917
0.006232.454929250.05250.95440.96330.95890.9917
0.005932.621429400.05250.95490.96380.95930.9917
0.005832.787829550.05310.95490.96420.95960.9917
0.00532.954229700.05330.95360.96330.95840.9916
0.00733.120729850.05330.95360.96330.95840.9916
0.004733.287130000.05320.95360.96330.95840.9916

Framework versions

  • Transformers 4.40.2
  • Pytorch 2.5.1
  • Datasets 2.19.0
  • Tokenizers 0.19.1