├── .gitignore ├── LICENSE ├── README.md ├── README.zh-CN.md ├── configs └── default.yaml ├── data ├── MMYOLO_model_data.csv ├── PaddleYOLO_extra_model_data.csv ├── PaddleYOLO_extra_para_data.csv ├── PaddleYOLO_model_data.csv ├── Pytorch_model_data.csv ├── Pytorch_models_data.csv ├── data.csv ├── data1.csv ├── llm_code_eval.csv ├── llm_eval_data.csv ├── mgm_2b_loss.txt ├── mllm_acc_eval-csv1029.csv ├── models_metrics.csv ├── result_cora.csv └── tree.json ├── example ├── leida_chart_mme.py └── run_test.ipynb ├── img ├── Average_vs_Python.png ├── JavaScript_vs_ C++.png ├── bar_chart_plot.jpg ├── data_csv.png ├── mllm_chart_acc1.png ├── paddle_plot_metrics.jpg ├── plot_metrics.jpg ├── plot_mult_chart.jpg ├── plot_mult_code_chart.jpg └── project_logo.png ├── main.py ├── mmplot ├── __init__.py ├── core │ ├── __init__.py │ └── run.py ├── data │ ├── MMYOLO_model_data.csv │ ├── PaddleYOLO_model_data.csv │ ├── Pytorch_model_data.csv │ ├── Pytorch_models_data.csv │ └── model_data.csv ├── plots │ ├── __init__.py │ ├── bar_chart_plot.py │ ├── line_metrics_plots.py │ ├── metrics_plots.py │ └── mult_chart_plot.py ├── utils │ ├── __init__.py │ ├── config.py │ ├── dataloader.py │ └── logger.py └── version.py ├── mmplot_test.py ├── output ├── bar_chart_plot.jpg └── plot_metrics.jpg ├── plots ├── __init__.py ├── bar_chart_plot.py ├── bar_metric_plot.py ├── data_plot.py ├── leida_chart_plot.py ├── line_metrics_plots.py ├── logic_tree_plot.py ├── model_layer_plt.py ├── model_loss_plt.py ├── model_per_plt.py ├── mult_chart_plot.py ├── pie_metric_plot.py ├── point_metric_plot.py ├── point_plot.py ├── pplot.py ├── seaborn_plots.py └── xlsx_tb_sort_plot.py ├── requirements.txt ├── setup.cfg ├── setup.py └── utils ├── __init__.py ├── colors.py ├── config.py ├── dataloader.py ├── excel_tools.py ├── fonts.py └── logger.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # model-metrics-plot 2 | 3 | ![](./img/project_logo.png) 4 | 5 | model-metrics-plot(mmplot) 6 | 7 | [English](README.md) | [简体中文](README.zh-CN.md) 8 | 9 | --- 10 | ![GitHub watchers](https://img.shields.io/github/watchers/isLinXu/model-metrics-plot.svg?style=social) ![GitHub stars](https://img.shields.io/github/stars/isLinXu/model-metrics-plot.svg?style=social) ![GitHub forks](https://img.shields.io/github/forks/isLinXu/model-metrics-plot.svg?style=social) ![GitHub followers](https://img.shields.io/github/followers/isLinXu.svg?style=social) 11 | [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fatrox%2Fsync-dotenv%2Fbadge&style=flat)](https://github.com/isLinXu/model-metrics-plot) ![img](https://badgen.net/badge/icon/learning?icon=deepscan&label)![GitHub repo size](https://img.shields.io/github/repo-size/isLinXu/model-metrics-plot.svg?style=flat-square) ![GitHub language count](https://img.shields.io/github/languages/count/isLinXu/model-metrics-plot) ![GitHub last commit](https://img.shields.io/github/last-commit/isLinXu/model-metrics-plot) ![GitHub](https://img.shields.io/github/license/isLinXu/model-metrics-plot.svg?style=flat-square)![img](https://hits.dwyl.com/isLinXu/model-metrics-plot.svg) 12 | 13 | ## 😎 About 14 | 15 | This project is developed based on libraries such as Pandas and Matplotlib, and can be used to draw line graphs of multiple index parameters such as algorithm accuracy and speed of multiple deep learning models. 16 | 17 | ## features 18 | 19 | use txt or log file to plot 20 | 21 | - [x] loss plot 22 | 23 | use csv data to plot 24 | - [x] line plot 25 | - [x] bar plot 26 | - [x] radar plot 27 | - [x] tree plot 28 | - [x] custom plot 29 | 30 | --- 31 | 32 | ## 🥰Result 33 | 34 | ### plot 35 | 36 | image 37 | 38 | | | ![](./img/paddle_plot_metrics.jpg) | | 39 | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | 40 | | [data/Pytorch_models_data.csv](https://github.com/isLinXu/model-metrics-plot/blob/main/data/Pytorch_models_data.csv) | [data/PaddleYOLO_models_data.csv](https://github.com/isLinXu/model-metrics-plot/blob/main/data/PaddleYOLO_model_data.csv) | [data/MMYOLO_model_data.csv](https://github.com/isLinXu/model-metrics-plot/blob/main/data/MMYOLO_model_data.csv) | 41 | 42 | | image | image | mllm_chart_acc1 | 43 | |-----------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------| 44 | | [data/llm_eval_data.csv](https://github.com/isLinXu/model-metrics-plot/blob/main/data/llm_eval_data.csv) | [data/tree.json](https://github.com/isLinXu/model-metrics-plot/blob/main/data/tree.json) | | 45 | | image | image | image | 46 | | image | bar | | 47 | 48 | --- 49 | 50 | ## 🔨Usage 51 | 52 | ### requirement 53 | 54 | ```shell 55 | pip install matplotlib 56 | pip install pandas 57 | ``` 58 | 59 | ### mmplot install 60 | 61 | ```shell 62 | git clone git@github.com:isLinXu/model-metrics-plot.git 63 | cd model-metrics-plot 64 | ``` 65 | 66 | ```shell 67 | pip install -e . 68 | ``` 69 | 70 | ### run 71 | 72 | ```shell 73 | python3 main.py 74 | ``` 75 | 76 | or use your custom data csv 77 | 78 | ```shell 79 | python3 main.py -c 'csv_path' -n 'figture_name' -p 'plot_type' -t 'title_name' -x 'xlabel_name' -y 'ylabel_name' -f font_size -g False -v 'value_type' -r 'colors' 80 | ``` 81 | 82 | #### line 83 | 84 | > python3 main.py -c data/model_data.csv -n 'plot.jpg' -p 'line' -t 'MS COCO Object Detection' -x 'PyTorch FP16 RTX3080(ms/img)' -y 'COCO Mask AP val' -f 10 -v 'mAP' -r '#0000FF' 85 | > 86 | 87 | ```shell 88 | python3 main.py -c data/PaddleYOLO_extra_model_data.csv -n 'plot.jpg' -p 'line' -t 'MS COCO Object Detection' -x 'PyTorch FP16 RTX3080(ms/img)' -y 'COCO Mask AP val' -f 10 -v 'mAP' -r '#0000FF' 89 | ``` 90 | 91 | image 92 | 93 | #### bar 94 | 95 | ```shell 96 | python3 main.py -c data/MMYOLO_model_data.csv -p bar 97 | ``` 98 | 99 | image 100 | 101 | #### radar 102 | 103 | 104 | ```shell 105 | python3 main.py -c data/mllm_acc_eval-csv1029.csv -p radar 106 | ``` 107 | 108 | ![image](https://github.com/isLinXu/issues/assets/59380685/7fa2d90d-55bc-4fa9-8e0c-899726e22425) 109 | 110 | #### tree 111 | 112 | image 113 | 114 | -------------------------------------------------------------------------------- /README.zh-CN.md: -------------------------------------------------------------------------------- 1 | # model-metrics-plot 2 | 3 | ![](./img/project_logo.png) 4 | 5 | model-metrics-plot(mmplot) 6 | 7 | [English](README.md) | [简体中文](README.zh-CN.md) 8 | 9 | --- 10 | ![GitHub watchers](https://img.shields.io/github/watchers/isLinXu/model-metrics-plot.svg?style=social) ![GitHub stars](https://img.shields.io/github/stars/isLinXu/model-metrics-plot.svg?style=social) ![GitHub forks](https://img.shields.io/github/forks/isLinXu/model-metrics-plot.svg?style=social) ![GitHub followers](https://img.shields.io/github/followers/isLinXu.svg?style=social) 11 | [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fatrox%2Fsync-dotenv%2Fbadge&style=flat)](https://github.com/isLinXu/model-metrics-plot) ![img](https://badgen.net/badge/icon/learning?icon=deepscan&label)![GitHub repo size](https://img.shields.io/github/repo-size/isLinXu/model-metrics-plot.svg?style=flat-square) ![GitHub language count](https://img.shields.io/github/languages/count/isLinXu/model-metrics-plot) ![GitHub last commit](https://img.shields.io/github/last-commit/isLinXu/model-metrics-plot) ![GitHub](https://img.shields.io/github/license/isLinXu/model-metrics-plot.svg?style=flat-square)![img](https://hits.dwyl.com/isLinXu/model-metrics-plot.svg) 12 | 13 | ## 😎 介绍 14 | 15 | 本项目基于Pandas、Matplotlib等库开发,可用于绘制多个深度学习模型的算法精度、速度等多个指标参数的折线图。 16 | 17 | --- 18 | 19 | ## 🥰结果 20 | 21 | ### 绘制结果 22 | 23 | | | ![](./img/paddle_plot_metrics.jpg) | | 24 | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | 25 | | [data/Pytorch_models_data.csv](https://github.com/isLinXu/model-metrics-plot/blob/main/data/Pytorch_models_data.csv) | [data/PaddleYOLO_models_data.csv](https://github.com/isLinXu/model-metrics-plot/blob/main/data/PaddleYOLO_model_data.csv) | [data/MMYOLO_model_data.csv](https://github.com/isLinXu/model-metrics-plot/blob/main/data/MMYOLO_model_data.csv) | 26 | 27 | | | | mllm_chart_acc1 | 28 | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | 29 | | [data/llm_eval_data.csv](https://github.com/isLinXu/model-metrics-plot/blob/main/data/llm_eval_data.csv) | [data/llm_eval_data.csv](https://github.com/isLinXu/model-metrics-plot/blob/main/data/llm_code_eval.csv) | | 30 | 31 | --- 32 | 33 | ## 🔨用法 34 | 35 | ### 依赖安装 36 | 37 | ```shell 38 | pip install matplotlib 39 | pip install pandas 40 | ``` 41 | 42 | ### mmplot安装 43 | 44 | ```shell 45 | git clone git@github.com:isLinXu/model-metrics-plot.git 46 | cd model-metrics-plot 47 | ``` 48 | 49 | ```shell 50 | pip install -e . 51 | ``` 52 | 53 | ### 使用 54 | 55 | 56 | ```shell 57 | python3 main.py 58 | ``` 59 | 60 | 或者,你可以使用自定义数据。 61 | 62 | 63 | ```shell 64 | python3 main.py -c 'csv_path' -n 'figture_name' -p 'plot_type' -t 'title_name' -x 'xlabel_name' -y 'ylabel_name' -f font_size -g False -v 'value_type' -r 'colors' 65 | ``` 66 | 67 | #### line 68 | 69 | > python3 main.py -c data/model_data.csv -n 'plot.jpg' -p 'line' -t 'MS COCO Object Detection' -x 'PyTorch FP16 RTX3080(ms/img)' -y 'COCO Mask AP val' -f 10 -v 'mAP' -r '#0000FF' 70 | > 71 | 72 | ```shell 73 | python3 main.py -c data/PaddleYOLO_extra_model_data.csv -n 'plot.jpg' -p 'line' -t 'MS COCO Object Detection' -x 'PyTorch FP16 RTX3080(ms/img)' -y 'COCO Mask AP val' -f 10 -v 'mAP' -r '#0000FF' 74 | ``` 75 | 76 | image 77 | 78 | #### bar 79 | 80 | ```shell 81 | python3 main.py -c data/MMYOLO_model_data.csv -p bar 82 | ``` 83 | 84 | image 85 | 86 | #### leida 87 | 88 | 89 | ```shell 90 | python3 main.py -c data/mllm_acc_eval-csv1029.csv -p leida 91 | ``` 92 | 93 | ![image](https://github.com/isLinXu/issues/assets/59380685/7fa2d90d-55bc-4fa9-8e0c-899726e22425) -------------------------------------------------------------------------------- /configs/default.yaml: -------------------------------------------------------------------------------- 1 | # model-metrics-plot 🚀 by isLinXu, GPL-3.0 license 2 | # Default ploting settings for model metrics 3 | 4 | data: "coco" 5 | mode: "" 6 | 7 | 8 | -------------------------------------------------------------------------------- /data/MMYOLO_model_data.csv: -------------------------------------------------------------------------------- 1 | model,branch,ms,fps,mAP 2 | YOLOv5,n,-1,-1,28 3 | YOLOv5,s,-1,-1,37.7 4 | YOLOv5,m,-1,-1,45.3 5 | YOLOv5,l,-1,-1,48.8 6 | YOLOv6,n,-1,-1,36.2 7 | YOLOv6,t,-1,-1,41.0 8 | YOLOv6,s,-1,-1,44.0 9 | YOLOv6,m,-1,-1,48.4 10 | YOLOv6,l,-1,-1,51.0 11 | YOLOv7,tiny,-1,-1,37.5 12 | YOLOv7,l,-1,-1,50.9 13 | YOLOv8,x,-1,-1,52.8 14 | PP-YOLOE,s,-1,-1,43.5 15 | PP-YOLOE,m,-1,-1,49.5 16 | PP-YOLOE,l,-1,-1,52.6 17 | PP-YOLOE,x,-1,-1,54.2 18 | -------------------------------------------------------------------------------- /data/PaddleYOLO_extra_model_data.csv: -------------------------------------------------------------------------------- 1 | model,branch,ms,fps,mAP,maker,release date,update,data source,test env 2 | YOLOv5,N,2.6,-1,28,.,May-20,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 3 | YOLOv5,S,3.2,-1,37.6,.,May-20,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.6/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 4 | YOLOv5,M,5.2,-1,45.4,.,May-20,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.7/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 5 | YOLOv5,L,7.9,-1,48.9,.,May-20,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.8/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 6 | YOLOv5,X,13.7,-1,50.6,.,May-20,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 7 | YOLOX,S,3,-1,40.4,.,Jul-21,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 8 | YOLOX,M,5.8,-1,46.9,.,Jul-21,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 9 | YOLOX,L,9.3,-1,50.1,.,Jul-21,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 10 | YOLOX,X,16.6,-1,51.8,.,Jul-21,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 11 | YOLOv7,L,7.4,-1,51,.,Jul-22,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 12 | YOLOv7,X,12.2,-1,53,.,Jul-22,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 13 | DAMO-YOLO,T,2.78,-1,43,.,Nov-22,2023/1/16,https://github.com/tinyvision/DAMO-YOLO,T4/FP16/trt8 14 | DAMO-YOLO,S,3.83,-1,46.8,.,Nov-22,2023/1/16,https://github.com/tinyvision/DAMO-YOLO,T4/FP16/trt8 15 | DAMO-YOLO,M,5.62,-1,50,.,Nov-22,2023/1/16,https://github.com/tinyvision/DAMO-YOLO,T4/FP16/trt8 16 | RTMDet,T,2.8,-1,40.9,.,Dec-22,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 17 | RTMDet,S,3.3,-1,44.5,.,Dec-22,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 18 | RTMDet,M,6.4,-1,49.1,.,Dec-22,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 19 | RTMDet,L,10.2,-1,51.2,.,Dec-22,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 20 | RTMDet,X,18,-1,52.6,.,Dec-22,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 21 | YOLOv8,N,2.4,-1,37.3,.,Jan-23,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 22 | YOLOv8,S,3.4,-1,44.9,.,Jan-23,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 23 | YOLOv8,M,6.5,-1,50.2,.,Jan-23,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 24 | YOLOv8,L,10,-1,52.8,.,Jan-23,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 25 | YOLOv8,X,15.1,-1,53.8,.,Jan-23,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 26 | YOLOv6_v3.0,N,1.3,-1,37.5,.,Jan-23,2023/1/16,https://arxiv.org/pdf/2301.05586.pdf,T4/FP16/trt7 27 | YOLOv6_v3.0,S,2.9,-1,45,.,Jan-23,2023/1/16,https://arxiv.org/pdf/2301.05586.pdf,T4/FP16/trt7 28 | YOLOv6_v3.0,M,5.7,-1,50,.,Jan-23,2023/1/16,https://arxiv.org/pdf/2301.05586.pdf,T4/FP16/trt7 29 | YOLOv6_v3.0,L,10.3,-1,53.1,.,Jan-23,2023/1/16,https://arxiv.org/pdf/2301.05586.pdf,T4/FP16/trt7 30 | PP-YOLOE+,S,2.9,-1,43.7,*,Sep-22,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 31 | PP-YOLOE+,M,6,-1,49.8,*,Sep-22,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 32 | PP-YOLOE+,L,8.7,-1,52.9,*,Sep-22,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 33 | PP-YOLOE+,X,14.9,-1,54.7,*,Sep-22,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 -------------------------------------------------------------------------------- /data/PaddleYOLO_extra_para_data.csv: -------------------------------------------------------------------------------- 1 | model,branch,ms,fps,mAP,maker,release date,update,data source,test env 2 | YOLOv5,N,1.9,-1,28,.,20-May,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 3 | YOLOv5,S,7.2,-1,37.6,.,20-May,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.6/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 4 | YOLOv5,M,21.2,-1,45.4,.,20-May,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.7/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 5 | YOLOv5,L,46.5,-1,48.9,.,20-May,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.8/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 6 | YOLOv5,X,86.7,-1,50.6,.,20-May,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 7 | YOLOX,S,9,-1,40.4,.,21-Jul,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 8 | YOLOX,M,25.3,-1,46.9,.,21-Jul,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 9 | YOLOX,L,54.2,-1,50.1,.,21-Jul,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 10 | YOLOX,X,99.1,-1,51.8,.,21-Jul,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 11 | YOLOv7,L,37.62,-1,51,.,22-Jul,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 12 | YOLOv7,X,71.34,-1,53,.,22-Jul,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 13 | DAMO-YOLO,T,8.5,-1,43,.,22-Nov,2023/1/16,https://github.com/tinyvision/DAMO-YOLO,T4/FP16/trt8 14 | DAMO-YOLO,S,16.3,-1,46.8,.,22-Nov,2023/1/16,https://github.com/tinyvision/DAMO-YOLO,T4/FP16/trt8 15 | DAMO-YOLO,M,28.2,-1,50,.,22-Nov,2023/1/16,https://github.com/tinyvision/DAMO-YOLO,T4/FP16/trt8 16 | RTMDet,T,4.8,-1,40.9,.,22-Dec,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 17 | RTMDet,S,8.89,-1,44.5,.,22-Dec,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 18 | RTMDet,M,24.71,-1,49.1,.,22-Dec,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 19 | RTMDet,L,52.3,-1,51.2,.,22-Dec,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 20 | RTMDet,X,94.86,-1,52.6,.,22-Dec,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 21 | YOLOv8,N,3.2,-1,37.3,.,23-Jan,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 22 | YOLOv8,S,11.2,-1,44.9,.,23-Jan,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 23 | YOLOv8,M,25.9,-1,50.2,.,23-Jan,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 24 | YOLOv8,L,43.7,-1,52.8,.,23-Jan,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 25 | YOLOv8,X,68.2,-1,53.8,.,23-Jan,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 26 | YOLOv6_v3.0,N,4.7,-1,37.5,.,23-Jan,2023/1/16,https://arxiv.org/pdf/2301.05586.pdf,T4/FP16/trt7 27 | YOLOv6_v3.0,S,18.5,-1,45,.,23-Jan,2023/1/16,https://arxiv.org/pdf/2301.05586.pdf,T4/FP16/trt7 28 | YOLOv6_v3.0,M,34.9,-1,50,.,23-Jan,2023/1/16,https://arxiv.org/pdf/2301.05586.pdf,T4/FP16/trt7 29 | YOLOv6_v3.0,L,59.6,-1,53.1,.,23-Jan,2023/1/16,https://arxiv.org/pdf/2301.05586.pdf,T4/FP16/trt7 30 | PP-YOLOE+,S,7.93,-1,43.7,*,22-Sep,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 31 | PP-YOLOE+,M,23.43,-1,49.8,*,22-Sep,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 32 | PP-YOLOE+,L,52.2,-1,52.9,*,22-Sep,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 33 | PP-YOLOE+,X,98.42,-1,54.7,*,22-Sep,2023/1/16,https://github.com/PaddlePaddle/PaddleYOLO/blob/release/2.5/docs/MODEL_ZOO_cn.md,T4/FP16/trt8 -------------------------------------------------------------------------------- /data/PaddleYOLO_model_data.csv: -------------------------------------------------------------------------------- 1 | model,branch,ms,fps,mAP,maker 2 | YOLOv5,n,2.6,-1,28,. 3 | YOLOv5,s,3.2,-1,37.6,. 4 | YOLOv5,m,5.2,-1,45.4,. 5 | YOLOv5,l,7.9,-1,48.9,. 6 | YOLOv5,x,13.7,-1,50.6,. 7 | YOLOv6,n,1.3,-1,36.1,. 8 | YOLOv6,t,2.1,-1,40.7,. 9 | YOLOv6,s,2.6,-1,43.4,. 10 | YOLOv6,m,5,-1,49,. 11 | YOLOv6,l,7.9,-1,51,. 12 | YOLOv6,l-silu,9.6,-1,51.7,. 13 | YOLOv7,l,7.4,-1,51,. 14 | YOLOv7,x,12.2,-1,53,. 15 | YOLOv8,n,2.4,-1,37.3,. 16 | YOLOv8,s,3.4,-1,44.9,. 17 | YOLOv8,m,6.5,-1,50.2,. 18 | YOLOv8,l,10,-1,52.8,. 19 | YOLOv8,x,15.1,-1,53.8,. 20 | YOLOX,s,3,-1,40.4,. 21 | YOLOX,m,5.8,-1,46.9,. 22 | YOLOX,l,9.3,-1,50.1,. 23 | YOLOX,x,16.6,-1,51.8,. 24 | RTMDet,t,2.8,-1,40.9,. 25 | RTMDet,s,3.3,-1,44.5,. 26 | RTMDet,m,6.4,-1,49.1,. 27 | RTMDet,l,10.2,-1,51.2,. 28 | RTMDet,x,18.0 ,-1,52.6,. 29 | PP-YOLOE+,s,2.9,-1,43.7,* 30 | PP-YOLOE+,m,6.0 ,-1,49.8,* 31 | PP-YOLOE+,l,8.7,-1,52.9,* 32 | PP-YOLOE+,x,14.9,-1,54.7,* 33 | -------------------------------------------------------------------------------- /data/Pytorch_model_data.csv: -------------------------------------------------------------------------------- 1 | model,branch,ms,fps,mAP 2 | YOLOv5,YOLOv5n,6.3,-1,28 3 | YOLOv5,YOLOv5s,6.4,-1,37.4 4 | YOLOv5,YOLOv5m,8.2,-1,45.4 5 | YOLOv5,YOLOv5l,10.1,-1,49 6 | YOLOv5,YOLOv5x,12.1,-1,50.7 7 | YOLOv6,YOLOv6-N,-1,779,37.5 8 | YOLOv6,YOLOv6-S,-1,339,45 9 | YOLOv6,YOLOv6-M,-1,175,50 10 | YOLOv6,YOLOv6-L,-1,98,52.8 11 | YOLOv6-6,YOLOv6-N6,-1,228,44.9 12 | YOLOv6-6,YOLOv6-S6,-1,98,50.3 13 | YOLOv6-6,YOLOv6-M6,-1,47,55.2 14 | YOLOv6-6,YOLOv6-L6,-1,26,57.2 15 | YOLOv7,YOLOv7,-1,161,51.4 16 | YOLOv7,YOLOv7-X,-1,114,53.1 17 | YOLOv7,YOLOv7-W6,-1,84,54.9 18 | YOLOv7,YOLOv7-E6,-1,56,56 19 | YOLOv7,YOLOv7-D6,-1,44,56.6 20 | YOLOv7,YOLOv7-E6E,-1,36,56.8 21 | YOLOv8,YOLOv8n,5.6,-1,37.3 22 | YOLOv8,YOLOv8s,5.7,-1,44.9 23 | YOLOv8,YOLOv8m,8.3,-1,50.2 24 | YOLOv8,YOLOv8l,13.1,-1,52.9 25 | YOLOv8,YOLOv8x,20.4,-1,53.9 26 | YOLOv8-seg,YOLOv8n-seg,11.3,-1,30.7 27 | YOLOv8-seg,YOLOv8s-seg,11.4,-1,37 28 | YOLOv8-seg,YOLOv8m-seg,15.3,-1,40.6 29 | YOLOv8-seg,YOLOv8l-seg,16.8,-1,42.5 30 | YOLOv8-seg,YOLOv8x-seg,23.8,-1,43.2 31 | -------------------------------------------------------------------------------- /data/Pytorch_models_data.csv: -------------------------------------------------------------------------------- 1 | model,branch,ms,fps,mAP,maker 2 | YOLOv5,n,6.3,-1,28,. 3 | YOLOv5,s,6.4,-1,37.4,. 4 | YOLOv5,m,8.2,-1,45.4,. 5 | YOLOv5,l,10.1,-1,49,. 6 | YOLOv5,x,12.1,-1,50.7,. 7 | YOLOv6,N,-1,779,37.5,s 8 | YOLOv6,S,-1,339,45,s 9 | YOLOv6,M,-1,175,50,s 10 | YOLOv6,L,-1,98,52.8,s 11 | YOLOv6-2.0,N6,-1,228,44.9,x 12 | YOLOv6-2.0,S6,-1,98,50.3,x 13 | YOLOv6-2.0,M6,-1,47,55.2,x 14 | YOLOv6-2.0,L6,-1,26,57.2,x 15 | YOLOv7,L,12.2,-1,51,v 16 | YOLOv7,X,19.4,-1,53,v 17 | YOLOv8,n,5.6,-1,37.3,o 18 | YOLOv8,s,5.7,-1,44.9,o 19 | YOLOv8,m,8.3,-1,50.2,o 20 | YOLOv8,l,13.1,-1,52.9,o 21 | YOLOv8,x,20.4,-1,53.9,o 22 | YOLOv8-seg,n-seg,11.3,-1,30.7,p 23 | YOLOv8-seg,s-seg,11.4,-1,37,p 24 | YOLOv8-seg,m-seg,15.3,-1,40.6,p 25 | YOLOv8-seg,l-seg,16.8,-1,42.5,p 26 | YOLOv8-seg,x-seg,23.8,-1,43.2,p 27 | -------------------------------------------------------------------------------- /data/data.csv: -------------------------------------------------------------------------------- 1 | date,category,value,x,y 2 | 2022-01-01,A,10,1,4 3 | 2022-01-02,A,20,2,5 4 | 2022-01-03,A,30,3,6 5 | 2022-01-01,B,15,4,7 6 | 2022-01-02,B,25,5,8 7 | 2022-01-03,B,35,6,9 -------------------------------------------------------------------------------- /data/data1.csv: -------------------------------------------------------------------------------- 1 | date,category,value,parent,child 2 | 2022-01-01,A,10,root,child1 3 | 2022-01-02,A,20,child1,child2 4 | 2022-01-03,A,30,child2,leaf1 5 | 2022-01-01,B,15,root,child3 6 | 2022-01-02,B,25,child3,child4 7 | 2022-01-03,B,35,child4,leaf2 -------------------------------------------------------------------------------- /data/llm_code_eval.csv: -------------------------------------------------------------------------------- 1 | Metric,Java, C++,Python,JavaScript,Average 2 | BLEU,0.401,0.174,0.297,0.199,0.268 3 | CodeBLEU,0.421,0.187,0.323,0.267,0.299 4 | chrF,0.413,0.198,0.312,0.22,0.286 5 | ROUGE-L,0.389,0.171,0.284,0.179,0.256 6 | METEOR,0.425,0.208,0.327,0.231,0.298 7 | RUBY,0.401,0.165,0.255,0.163,0.246 8 | CodeBERTScore-F1 (w/o S.),0.398,0.175,0.283,0.176,0.258 9 | CodeBERTScore-F1 (w/ S.),0.375,0.177,0.276,0.172,0.25 10 | CodeBERTScore-F3 (w/o S.),0.429,0.202,0.316,0.214,0.29 11 | CodeBERTScore-F3 (w/ S.),0.426,0.198,0.312,0.226,0.291 12 | GPT-3.5 (w/o R.),0.442,0.326,0.282,0.321,0.343 13 | GPT-3.5 (w/ R.),0.404,0.282,0.325,0.348,0.34 -------------------------------------------------------------------------------- /data/llm_eval_data.csv: -------------------------------------------------------------------------------- 1 | Model,Harmlessness,Helpfulness,Honesty,Other,Avg. 2 | ChatGPT,90.7,91.2,78.1,86.3,86.6 3 | Flan-Alpaca-11B,74.2,81.4,77.4,83.4,79.1 4 | Tk-Instruct-11B,75.9,75.3,75.1,79.6,76.7 5 | T5-11B,46.4,54.8,62.3,76.0,65.8 6 | StableVicuna-13B,61.7,67.2,57.1,79.1,66.3 7 | Vicuna-13B,60.3,70.1,55.1,78.2,65.9 8 | Alpaca-13B,49.7,51.2,51.8,45.5,49.5 9 | LLaMA-13B,57.2,61.0,57.0,72.0,61.8 10 | Dolly V2-12B,51.7,59.9,47.0,58.1,54.2 11 | Pythia-12B,41.3,46.1,43.6,49.3,45.1 -------------------------------------------------------------------------------- /data/mgm_2b_loss.txt: -------------------------------------------------------------------------------- 1 | {'loss': 13.3247, 'grad_norm': 274.79765799244865, 'learning_rate': 0.0002, 'epoch': 0.01} 2 | {'loss': 12.959, 'grad_norm': 217.1427744528247, 'learning_rate': 0.0004, 'epoch': 0.02} 3 | {'loss': 10.0544, 'grad_norm': 54.6807695443335, 'learning_rate': 0.0008, 'epoch': 0.03} 4 | {'loss': 40.0117, 'grad_norm': 345.42176094179257, 'learning_rate': 0.001, 'epoch': 0.03} 5 | {'loss': 29.4648, 'grad_norm': 293.63161645858577, 'learning_rate': 0.0009998917893031614, 'epoch': 0.04} 6 | {'loss': 14.7905, 'grad_norm': 107.64133328545186, 'learning_rate': 0.0009995672040508656, 'epoch': 0.04} 7 | {'loss': 10.4011, 'grad_norm': 53.56760156967312, 'learning_rate': 0.0009990263847374976, 'epoch': 0.05} 8 | {'loss': 9.2124, 'grad_norm': 28.13532257535121, 'learning_rate': 0.0009982695654527965, 'epoch': 0.06} 9 | {'loss': 9.8577, 'grad_norm': 20.970012299907427, 'learning_rate': 0.0009972970737805312, 'epoch': 0.06} 10 | {'loss': 9.5713, 'grad_norm': 19.08898577821852, 'learning_rate': 0.0009961093306567075, 'epoch': 0.07} 11 | {'loss': 8.8416, 'grad_norm': 18.456439239049793, 'learning_rate': 0.00099470685018737, 'epoch': 0.08} 12 | {'loss': 8.8267, 'grad_norm': 16.751892593646247, 'learning_rate': 0.0009930902394260745, 'epoch': 0.08} 13 | {'loss': 8.5441, 'grad_norm': 16.758408650106972, 'learning_rate': 0.0009912601981111285, 'epoch': 0.09} 14 | {'loss': 8.2969, 'grad_norm': 9.651561269996273, 'learning_rate': 0.000989217518362716, 'epoch': 0.1} 15 | {'loss': 8.1541, 'grad_norm': 6.35246851571837, 'learning_rate': 0.000986963084340033, 'epoch': 0.1} 16 | {'loss': 8.0247, 'grad_norm': 5.946657930373748, 'learning_rate': 0.0009844978718585855, 'epoch': 0.11} 17 | {'loss': 7.7036, 'grad_norm': 5.2340777379469285, 'learning_rate': 0.0009818229479678158, 'epoch': 0.12} 18 | {'loss': 7.8181, 'grad_norm': 4.754085092552073, 'learning_rate': 0.0009789394704892364, 'epoch': 0.12} 19 | {'loss': 7.7974, 'grad_norm': 4.378488013106178, 'learning_rate': 0.0009758486875152766, 'epoch': 0.13} 20 | {'loss': 7.7769, 'grad_norm': 4.173901372803682, 'learning_rate': 0.0009725519368690539, 'epoch': 0.13} 21 | {'loss': 7.5269, 'grad_norm': 4.120861664277592, 'learning_rate': 0.0009690506455253072, 'epoch': 0.14} 22 | {'loss': 7.6575, 'grad_norm': 3.62742247876934, 'learning_rate': 0.000965346328992741, 'epoch': 0.15} 23 | {'loss': 7.5067, 'grad_norm': 3.4672709008981974, 'learning_rate': 0.0009614405906580486, 'epoch': 0.15} 24 | {'loss': 7.4841, 'grad_norm': 2.9743471913392017, 'learning_rate': 0.0009573351210918975, 'epoch': 0.16} 25 | {'loss': 7.4661, 'grad_norm': 3.087586150669912, 'learning_rate': 0.000953031697317178, 'epoch': 0.17} 26 | {'loss': 7.2271, 'grad_norm': 2.9030206321457532, 'learning_rate': 0.0009485321820398321, 'epoch': 0.17} 27 | {'loss': 7.0156, 'grad_norm': 2.461066845657519, 'learning_rate': 0.0009438385228425939, 'epoch': 0.18} 28 | {'loss': 7.0973, 'grad_norm': 2.451541481087895, 'learning_rate': 0.0009389527513419935, 'epoch': 0.19} 29 | {'loss': 7.1892, 'grad_norm': 2.3862265407677454, 'learning_rate': 0.0009338769823089853, 'epoch': 0.19} 30 | {'loss': 6.8342, 'grad_norm': 2.243132509753661, 'learning_rate': 0.0009286134127535859, 'epoch': 0.2} 31 | {'loss': 6.8745, 'grad_norm': 2.0714523927676525, 'learning_rate': 0.0009231643209739127, 'epoch': 0.2} 32 | {'loss': 6.8798, 'grad_norm': 2.090691945767049, 'learning_rate': 0.0009175320655700406, 'epoch': 0.21} 33 | {'loss': 6.9299, 'grad_norm': 2.1467972669803586, 'learning_rate': 0.0009117190844230972, 'epoch': 0.22} 34 | {'loss': 7.041, 'grad_norm': 2.0621234665128325, 'learning_rate': 0.0009057278936400453, 'epoch': 0.22} 35 | {'loss': 6.8503, 'grad_norm': 1.999200907067321, 'learning_rate': 0.0008995610864646028, 'epoch': 0.23} 36 | {'loss': 6.8308, 'grad_norm': 1.8994706460166302, 'learning_rate': 0.0008932213321547768, 'epoch': 0.24} 37 | {'loss': 6.8611, 'grad_norm': 1.946914141963594, 'learning_rate': 0.000886711374827494, 'epoch': 0.24} 38 | {'loss': 6.8196, 'grad_norm': 1.9257573231807563, 'learning_rate': 0.0008800340322708292, 'epoch': 0.25} 39 | {'loss': 6.7924, 'grad_norm': 1.8715754344519386, 'learning_rate': 0.0008731921947243468, 'epoch': 0.26} 40 | {'loss': 6.7205, 'grad_norm': 1.9027514589617507, 'learning_rate': 0.0008661888236280813, 'epoch': 0.26} 41 | {'loss': 6.5638, 'grad_norm': 1.7009488386515181, 'learning_rate': 0.0008590269503406985, 'epoch': 0.27} 42 | {'loss': 6.6914, 'grad_norm': 1.752272631914034, 'learning_rate': 0.0008517096748273951, 'epoch': 0.28} 43 | {'loss': 6.6282, 'grad_norm': 1.6400902641235713, 'learning_rate': 0.0008442401643181, 'epoch': 0.28} 44 | {'loss': 6.606, 'grad_norm': 1.6288405669836403, 'learning_rate': 0.0008366216519365621, 'epoch': 0.29} 45 | {'loss': 6.4937, 'grad_norm': 1.521585148694056, 'learning_rate': 0.0008288574353009164, 'epoch': 0.29} 46 | {'loss': 6.5981, 'grad_norm': 1.4840680993478215, 'learning_rate': 0.0008209508750963328, 'epoch': 0.3} 47 | {'loss': 6.6313, 'grad_norm': 1.4619769812145655, 'learning_rate': 0.0008129053936203688, 'epoch': 0.31} 48 | {'loss': 6.5591, 'grad_norm': 1.44674401960222, 'learning_rate': 0.0008047244733016521, 'epoch': 0.31} 49 | {'loss': 6.6904, 'grad_norm': 1.3623998629016818, 'learning_rate': 0.0007964116551925364, 'epoch': 0.32} 50 | {'loss': 6.5132, 'grad_norm': 1.3380131059379214, 'learning_rate': 0.0007879705374363831, 'epoch': 0.33} 51 | {'loss': 6.4243, 'grad_norm': 1.3344576709082498, 'learning_rate': 0.0007794047737101297, 'epoch': 0.33} 52 | {'loss': 6.4861, 'grad_norm': 1.2841584494982148, 'learning_rate': 0.0007707180716428237, 'epoch': 0.34} 53 | {'loss': 6.3134, 'grad_norm': 1.2745682563369738, 'learning_rate': 0.0007619141912108007, 'epoch': 0.35} 54 | {'loss': 6.3285, 'grad_norm': 1.2719415657326627, 'learning_rate': 0.0007529969431102063, 'epoch': 0.35} 55 | {'loss': 6.3201, 'grad_norm': 1.2063536243822626, 'learning_rate': 0.0007439701871075642, 'epoch': 0.36} 56 | {'loss': 6.4868, 'grad_norm': 1.1657240824024777, 'learning_rate': 0.000734837830369103, 'epoch': 0.36} 57 | {'loss': 6.3477, 'grad_norm': 1.1832563532437084, 'learning_rate': 0.0007256038257695687, 'epoch': 0.37} 58 | {'loss': 6.3129, 'grad_norm': 1.1677501070365042, 'learning_rate': 0.0007162721701812506, 'epoch': 0.38} 59 | {'loss': 6.4896, 'grad_norm': 1.2457709949909557, 'learning_rate': 0.0007068469027439641, 'epoch': 0.38} 60 | {'loss': 6.3727, 'grad_norm': 1.1378282702608244, 'learning_rate': 0.0006973321031167382, 'epoch': 0.39} 61 | {'loss': 6.2786, 'grad_norm': 1.0950938751561508, 'learning_rate': 0.0006877318897119651, 'epoch': 0.4} 62 | {'loss': 6.1874, 'grad_norm': 1.066194820317176, 'learning_rate': 0.0006780504179127734, 'epoch': 0.4} 63 | {'loss': 6.2169, 'grad_norm': 1.015025762159081, 'learning_rate': 0.0006682918782744032, 'epoch': 0.41} 64 | {'loss': 6.2834, 'grad_norm': 1.046886748436303, 'learning_rate': 0.0006584604947103514, 'epoch': 0.42} 65 | {'loss': 6.1738, 'grad_norm': 0.9703471405954925, 'learning_rate': 0.0006485605226640837, 'epoch': 0.42} 66 | {'loss': 6.3813, 'grad_norm': 1.0756150256063441, 'learning_rate': 0.0006385962472670953, 'epoch': 0.43} 67 | {'loss': 6.3408, 'grad_norm': 1.0073410500596307, 'learning_rate': 0.000628571981484123, 'epoch': 0.44} 68 | {'loss': 6.1543, 'grad_norm': 0.9672806099710086, 'learning_rate': 0.0006184920642463094, 'epoch': 0.44} 69 | {'loss': 6.1685, 'grad_norm': 0.9491155863301582, 'learning_rate': 0.0006083608585731282, 'epoch': 0.45} 70 | {'loss': 6.2896, 'grad_norm': 1.020788690694101, 'learning_rate': 0.0005981827496838822, 'epoch': 0.45} 71 | {'loss': 6.0531, 'grad_norm': 0.9173075437567809, 'learning_rate': 0.0005879621430995928, 'epoch': 0.46} 72 | {'loss': 6.1104, 'grad_norm': 0.9346244293892392, 'learning_rate': 0.0005777034627361025, 'epoch': 0.47} 73 | {'loss': 6.3159, 'grad_norm': 0.9764179459664736, 'learning_rate': 0.0005674111489892144, 'epoch': 0.47} 74 | {'loss': 6.1084, 'grad_norm': 0.9118270485739178, 'learning_rate': 0.0005570896568126993, 'epoch': 0.48} 75 | {'loss': 6.0969, 'grad_norm': 0.8904093492611471, 'learning_rate': 0.00054674345379, 'epoch': 0.49} 76 | {'loss': 6.2231, 'grad_norm': 0.9106767940335139, 'learning_rate': 0.000536377018200472, 'epoch': 0.49} 77 | {'loss': 6.0017, 'grad_norm': 0.8895040718426537, 'learning_rate': 0.0005259948370809901, 'epoch': 0.5} 78 | {'loss': 6.23, 'grad_norm': 0.9230511809365086, 'learning_rate': 0.0005156014042837695, 'epoch': 0.51} 79 | {'loss': 6.0436, 'grad_norm': 0.8606939928507132, 'learning_rate': 0.0005052012185312321, 'epoch': 0.51} 80 | {'loss': 6.0659, 'grad_norm': 0.8974483704958306, 'learning_rate': 0.0004947987814687679, 'epoch': 0.52} 81 | {'loss': 6.0994, 'grad_norm': 0.8783147798842145, 'learning_rate': 0.00048439859571623034, 'epoch': 0.52} 82 | {'loss': 6.2146, 'grad_norm': 0.8866967641061887, 'learning_rate': 0.00047400516291900993, 'epoch': 0.53} 83 | {'loss': 6.1749, 'grad_norm': 0.8673334760176641, 'learning_rate': 0.0004636229817995281, 'epoch': 0.54} 84 | {'loss': 6.1204, 'grad_norm': 0.8640468828218396, 'learning_rate': 0.0004532565462099999, 'epoch': 0.54} 85 | {'loss': 6.0882, 'grad_norm': 0.8705695253959916, 'learning_rate': 0.00044291034318730087, 'epoch': 0.55} 86 | {'loss': 6.0515, 'grad_norm': 0.8450947589853008, 'learning_rate': 0.0004325888510107856, 'epoch': 0.56} 87 | {'loss': 6.1005, 'grad_norm': 0.8169944484696877, 'learning_rate': 0.0004222965372638976, 'epoch': 0.56} 88 | {'loss': 6.0547, 'grad_norm': 0.8588250138492506, 'learning_rate': 0.00041203785690040743, 'epoch': 0.57} 89 | {'loss': 6.0649, 'grad_norm': 0.8371953452422528, 'learning_rate': 0.00040181725031611794, 'epoch': 0.58} 90 | {'loss': 6.1382, 'grad_norm': 0.8572090140790919, 'learning_rate': 0.0003916391414268718, 'epoch': 0.58} 91 | {'loss': 5.9756, 'grad_norm': 0.7702431477575846, 'learning_rate': 0.00038150793575369063, 'epoch': 0.59} 92 | {'loss': 6.1284, 'grad_norm': 0.8138677940313896, 'learning_rate': 0.00037142801851587707, 'epoch': 0.6} 93 | {'loss': 6.1704, 'grad_norm': 0.8789066179344281, 'learning_rate': 0.00036140375273290476, 'epoch': 0.6} 94 | {'loss': 6.1492, 'grad_norm': 0.8690697099169089, 'learning_rate': 0.0003514394773359163, 'epoch': 0.61} 95 | {'loss': 6.3064, 'grad_norm': 0.8933865174124493, 'learning_rate': 0.0003415395052896487, 'epoch': 0.61} 96 | {'loss': 6.2583, 'grad_norm': 0.9190766705055621, 'learning_rate': 0.00033170812172559694, 'epoch': 0.62} 97 | {'loss': 5.9756, 'grad_norm': 0.7949175537704982, 'learning_rate': 0.00032194958208722654, 'epoch': 0.63} 98 | {'loss': 6.0264, 'grad_norm': 0.8137445153597281, 'learning_rate': 0.00031226811028803515, 'epoch': 0.63} 99 | {'loss': 6.1335, 'grad_norm': 0.8361489259888061, 'learning_rate': 0.00030266789688326184, 'epoch': 0.64} 100 | {'loss': 6.1587, 'grad_norm': 0.8825063868435945, 'learning_rate': 0.00029315309725603595, 'epoch': 0.65} 101 | {'loss': 6.1333, 'grad_norm': 0.8200493447937667, 'learning_rate': 0.00028372782981874963, 'epoch': 0.65} 102 | {'loss': 6.1221, 'grad_norm': 0.802152495030578, 'learning_rate': 0.00027439617423043145, 'epoch': 0.66} 103 | {'loss': 6.0006, 'grad_norm': 0.7950182183400193, 'learning_rate': 0.00026516216963089694, 'epoch': 0.67} 104 | {'loss': 6.1089, 'grad_norm': 0.8226233506033952, 'learning_rate': 0.0002560298128924358, 'epoch': 0.67} 105 | {'loss': 6.0925, 'grad_norm': 0.8329141702962262, 'learning_rate': 0.0002470030568897938, 'epoch': 0.68} 106 | {'loss': 6.0023, 'grad_norm': 0.7741381536298394, 'learning_rate': 0.00023808580878919945, 'epoch': 0.68} 107 | {'loss': 6.1694, 'grad_norm': 0.8193796126162314, 'learning_rate': 0.00022928192835717644, 'epoch': 0.69} 108 | {'loss': 6.0767, 'grad_norm': 0.998501056972632, 'learning_rate': 0.00022059522628987038, 'epoch': 0.7} 109 | {'loss': 6.0569, 'grad_norm': 0.7563780052757422, 'learning_rate': 0.0002120294625636171, 'epoch': 0.7} 110 | {'loss': 6.0525, 'grad_norm': 0.7779739557912192, 'learning_rate': 0.00020358834480746363, 'epoch': 0.71} 111 | {'loss': 5.9829, 'grad_norm': 0.7590744736566645, 'learning_rate': 0.00019527552669834798, 'epoch': 0.72} 112 | {'loss': 5.9414, 'grad_norm': 0.790964755389917, 'learning_rate': 0.00018709460637963122, 'epoch': 0.72} 113 | {'loss': 6.1084, 'grad_norm': 0.8300727353552143, 'learning_rate': 0.00017904912490366722, 'epoch':0.73} 114 | {'loss': 6.0583, 'grad_norm': 0.8009898376001356, 'learning_rate': 0.0001711425646990838, 'epoch': 0.74} 115 | {'loss': 5.9246, 'grad_norm': 0.7747211613116931, 'learning_rate': 0.00016337834806343782, 'epoch': 0.74} 116 | {'loss': 5.9277, 'grad_norm': 0.8072034101227853, 'learning_rate': 0.0001557598356819, 'epoch': 0.75} 117 | {'loss': 6.1091, 'grad_norm': 0.8114190700939747, 'learning_rate': 0.00014829032517260488, 'epoch': 0.76} 118 | {'loss': 5.9722, 'grad_norm': 0.7662680117713779, 'learning_rate': 0.00014097304965930157, 'epoch': 0.76} 119 | {'loss': 6.0167, 'grad_norm': 0.825981108997375, 'learning_rate': 0.00013381117637191887, 'epoch': 0.77} 120 | {'loss': 5.9613, 'grad_norm': 0.7934956748336955, 'learning_rate': 0.00012680780527565312, 'epoch': 0.77} 121 | {'loss': 5.8896, 'grad_norm': 0.7671462194961516, 'learning_rate': 0.0001199659677291709, 'epoch': 0.78} 122 | {'loss': 6.0745, 'grad_norm': 0.760736536677498, 'learning_rate': 0.00011328862517250609, 'epoch': 0.79} 123 | {'loss': 5.974, 'grad_norm': 0.7417064054500705, 'learning_rate': 0.00010677866784522316, 'epoch': 0.79} 124 | {'loss': 6.1221, 'grad_norm': 0.7647614290436064, 'learning_rate': 0.0001004389135353972, 'epoch': 0.8} 125 | {'loss': 6.1061, 'grad_norm': 0.7964120498460867, 'learning_rate': 9.427210635995481e-05, 'epoch': 0.81} 126 | {'loss': 5.929, 'grad_norm': 0.7344561780203244, 'learning_rate': 8.828091557690287e-05, 'epoch': 0.81} 127 | {'loss': 5.9653, 'grad_norm': 0.7877348918406729, 'learning_rate': 8.246793442995954e-05, 'epoch': 0.82} 128 | {'loss': 6.0389, 'grad_norm': 0.8180598935660033, 'learning_rate': 7.683567902608729e-05, 'epoch': 0.83} 129 | {'loss': 6.0676, 'grad_norm': 0.783914890010839, 'learning_rate': 7.138658724641417e-05, 'epoch': 0.83} 130 | {'loss': 6.1154, 'grad_norm': 0.8454171539605627, 'learning_rate': 6.612301769101465e-05, 'epoch': 0.84} 131 | {'loss': 5.9846, 'grad_norm': 0.7871065608385753, 'learning_rate': 6.104724865800665e-05, 'epoch': 0.84} 132 | {'loss': 5.9385, 'grad_norm': 0.7924557431053013, 'learning_rate': 5.61614771574061e-05, 'epoch': 0.85} 133 | {'loss': 6.1069, 'grad_norm': 0.7476299452219785, 'learning_rate': 5.1467817960167975e-05, 'epoch': 0.86} 134 | {'loss': 5.9449, 'grad_norm': 0.7249783142674877, 'learning_rate': 4.696830268282204e-05, 'epoch': 0.86} 135 | {'loss': 6.0483, 'grad_norm': 0.7939812477981344, 'learning_rate': 4.266487890810256e-05, 'epoch': 0.87} 136 | {'loss': 6.0217, 'grad_norm': 0.7814601174097641, 'learning_rate': 3.8559409341951456e-05, 'epoch': 0.88} 137 | {'loss': 6.0049, 'grad_norm': 0.75210631022833, 'learning_rate': 3.465367100725908e-05, 'epoch': 0.88} 138 | {'loss': 6.051, 'grad_norm': 0.8207315947247086, 'learning_rate': 3.094935447469294e-05, 'epoch': 0.89} 139 | {'loss': 6.0388, 'grad_norm': 0.7813858779263245, 'learning_rate': 2.7448063130946223e-05, 'epoch': 0.9} 140 | {'loss': 5.9873, 'grad_norm': 0.7949833627670231, 'learning_rate': 2.4151312484723464e-05, 'epoch': 0.9} 141 | {'loss': 5.9664, 'grad_norm': 0.7859323773069914, 'learning_rate': 2.1060529510763648e-05, 'epoch': 0.91} 142 | {'loss': 5.9862, 'grad_norm': 0.7690577833417672, 'learning_rate': 1.8177052032184282e-05, 'epoch': 0.92} 143 | {'loss': 6.1223, 'grad_norm': 0.7500479760718313, 'learning_rate': 1.5502128141414497e-05, 'epoch': 0.92} 144 | {'loss': 6.0544, 'grad_norm': 0.7450622805471262, 'learning_rate': 1.3036915659967118e-05, 'epoch': 0.93} 145 | {'loss': 6.0413, 'grad_norm': 0.7703702956556486, 'learning_rate': 1.0782481637284013e-05, 'epoch': 0.93} 146 | {'loss': 5.939, 'grad_norm': 0.7715879647375541, 'learning_rate': 8.739801888871469e-06, 'epoch': 0.94} 147 | {'loss': 5.8521, 'grad_norm': 0.7584307003493879, 'learning_rate': 6.909760573925561e-06, 'epoch': 0.95} 148 | {'loss': 6.0408, 'grad_norm': 0.765669993722487, 'learning_rate': 5.2931498126298495e-06, 'epoch': 0.95} 149 | {'loss': 6.0195, 'grad_norm': 0.7718179724864959, 'learning_rate': 3.890669343292464e-06, 'epoch': 0.96} 150 | {'loss': 6.0298, 'grad_norm': 0.7604880484793223, 'learning_rate': 2.7029262194688818e-06, 'epoch': 0.97} 151 | {'loss': 6.0571, 'grad_norm': 0.7567059919200881, 'learning_rate': 1.7304345472035632e-06, 'epoch': 0.97} 152 | {'loss': 6.0206, 'grad_norm': 0.8225593257036284, 'learning_rate': 9.73615262502503e-07, 'epoch': 0.98} 153 | {'loss': 6.0762, 'grad_norm': 0.7874648527226416, 'learning_rate': 4.3279594913447906e-07, 'epoch': 0.99} 154 | {'loss': 5.9304, 'grad_norm': 0.7616324518756692, 'learning_rate': 1.082106968385288e-07, 'epoch': 0.99} -------------------------------------------------------------------------------- /data/mllm_acc_eval-csv1029.csv: -------------------------------------------------------------------------------- 1 | Model,Existence,Count,Position,Color,Poster,Celebrity,Scene,Landmark,Artwork,Commensense Reasoning,OCR,Numerical Calculation,Text Translation,Code Reasoning 2 | WeMM,195,128.33,85.8,168.33,169.39,163.82,171.75,151.75,155.75,111.43,162.5,62.5,87.5,45 3 | Lion,190,155,153.33,180,181.63,150.59,159,173,130.75,125.71,72.5,105,147.5,67.5 4 | SPHINX,195,160,153.33,160,164.29,177.94,160,168.09,134,130,87.5,55,75,50 5 | InternLM-XComposer-VL,190,158.33,126.67,165,161.9,150.29,159.75,165.25,126.25,138.57,125,55,112.5,85 6 | Qwen-VL-Chat,158.33,150,128.33,170,178.57,120.59,152.25,164,125.5,130.71,140,40,147.5,42.5 7 | GPT-4V,190,160,95,150,192.18,0,151,138.25,148,142.14,185,130,75,170 -------------------------------------------------------------------------------- /data/models_metrics.csv: -------------------------------------------------------------------------------- 1 | Model,FPS,mAP,Category 2 | GLIPv1-T,5,30,GLIPv1-T 3 | GLIPv2-T,7,32,GLIPv2-T 4 | Grounding DINO-T,6,31,Grounding DINO-T 5 | DetCLIP-T,4,29,DetCLIP-T 6 | YOLO-World-S,50,40,YOLO-World-S 7 | YOLO-World-M,60,42,YOLO-World-M 8 | YOLO-World-L,70,45,YOLO-World-L -------------------------------------------------------------------------------- /data/result_cora.csv: -------------------------------------------------------------------------------- 1 | LR(%),Random,HyperNAS-RL,HyperNAS 2 | std,82.8,83.3,83.9 3 | 2,78.1,78.6,79.1 4 | 5.2,81.4,81.9,82.4 5 | 10,83.8,84.1,84.5 6 | 20,84.1,84.6,84.9 7 | 30,85.1,85.3,85.6 8 | 44,85.6,85.9,86.1 -------------------------------------------------------------------------------- /data/tree.json: -------------------------------------------------------------------------------- 1 | { 2 | "A": ["B", "C"], 3 | "B": ["D", "E"], 4 | "C": ["F", "G"], 5 | "D": ["H", "I"], 6 | "E": [], 7 | "F": [], 8 | "G": [], 9 | "H": [], 10 | "I": [] 11 | } -------------------------------------------------------------------------------- /example/leida_chart_mme.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | from matplotlib import rcParams 3 | import pandas as pd 4 | import numpy as np 5 | 6 | from utils.colors import colors_dark,colors_light,colors_classic,colors_common,colors_dark_private,colors_common_private,colors_hex 7 | from utils.fonts import font_new_roman 8 | 9 | 10 | def plot_evaluation_chart(csv_path, output_path='evaluation_chart_1116.png', font_size=25, figsize=(16, 16)): 11 | # 设置全局字体为Times New Roman 12 | rcParams['font.family'] = 'Times New Roman' 13 | 14 | # 读取CSV文件并提取数据 15 | data_frame = pd.read_csv(csv_path) 16 | categories = list(data_frame.columns[1:]) 17 | values = data_frame.values[:, 1:] 18 | model_labels = data_frame.values[:, 0] 19 | 20 | # 计算角度并闭合多边形 21 | angles = np.linspace(0, 2 * np.pi, len(categories), endpoint=False).tolist() 22 | angles += angles[:1] 23 | 24 | # 创建极坐标图并设置大小 25 | fig, ax = plt.subplots(figsize=figsize, subplot_kw=dict(polar=True)) 26 | 27 | # 设置坐标标签字体大小 28 | plt.xticks(fontsize=font_size) 29 | plt.yticks(fontsize=font_size) 30 | 31 | # 隐藏最外圈的圆 32 | ax.spines['polar'].set_visible(False) 33 | 34 | # 绘制每一行数据的多边形 35 | for i, row in enumerate(values): 36 | # cr = colors_dark[i] 37 | # cr = colors_light[i] 38 | # cr = colors_classic[i] 39 | # cr = colors_common[i] 40 | # cr = colors_dark_private[i] 41 | cr = colors_common_private[i] 42 | # cr = colors_3model[i] 43 | data = np.concatenate((row, [row[0]])) # 闭合多边形 44 | label_name = model_labels[i] 45 | ax.fill(angles, data, alpha=0.25,color=cr) # 填充多边形 46 | ax.plot(angles, data, label=label_name, linewidth=2.0,color=cr) # 绘制多边形 47 | 48 | # 设置图例属性 49 | num_models = len(values) 50 | legend = ax.legend(bbox_to_anchor=(0.5, -0.15), loc='lower center', ncol=num_models, prop=font_new_roman) 51 | # legend = ax.legend(bbox_to_anchor=(0.5, -0.15), loc='lower center', ncol=, prop=font_new_roman ) 52 | for line in legend.get_lines(): 53 | line.set_linewidth(5) 54 | 55 | # 设置刻度、标签和标题 56 | ax.set_xticks(angles[:-1]) 57 | ax.set_xticklabels(categories) 58 | 59 | # 显示并保存图形 60 | plt.show() 61 | fig.savefig(output_path, dpi=300, bbox_inches='tight', transparent=True) 62 | 63 | 64 | if __name__ == '__main__': 65 | # csv_path = '../data/mllm_acc_eval-csv1029.csv' 66 | # csv_path = '../data/mllm_acc_eval-csv1116.csv' 67 | # csv_path = '../data/csv/mllm_acc_eval-csv1110.csv' 68 | # csv_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/mllm_acc_eval-csv1117.csv' 69 | # output_path = 'evaluation_chart_1117.png' 70 | 71 | # csv_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/mllm_acc_eval-csv1123.csv' 72 | # csv_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/research/mllm_acc_eval_FlanT5xxl_csv1125.csv' 73 | # csv_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/research/mllm_acc_eval_llama_csv1125.csv' 74 | # csv_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/research/mllm_acc_eval_vicuna_csv1125.csv' 75 | # csv_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/research/mllm_acc_eval-csv1207.csv' 76 | # csv_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/research/mllm_acc_eval-csv_private_1207.csv' 77 | # output_path = 'chart/evaluation_chart_private_1211.png' 78 | 79 | # csv_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/research/mllm_acc_eval_3model_csv1217.csv' 80 | # output_path = 'chart/evaluation_chart_3model_1218.png' 81 | 82 | # csv_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/research/mllm_acc_eval-csv_public_1217.csv' 83 | # output_path = 'chart/evaluation_chart_public_1217.png' 84 | 85 | # csv_path = ' /Users/gatilin/PycharmProjects/model-metrics-plot/data/research/mllm_acc_eval-csv_private_1217.csv' 86 | # output_path = 'chart/evaluation_chart_private_1217.png' 87 | 88 | # csv_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/research/mllm_acc_eval-csv_public_1211.csv' 89 | # output_path = 'chart/evaluation_chart_public_1211.png' 90 | # output_path = 'chart/evaluation_chart_vicuna_1125.png' 91 | 92 | # csv_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/research/mllm_acc_eval-csv_private_1230.csv' 93 | # output_path = 'chart/evaluation_chart_private_1230.png' 94 | csv_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/research/mllm_acc_eval-csv_private_0128.csv' 95 | output_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/plots/chart/evaluation_chart_public_0128.png' 96 | 97 | plot_evaluation_chart(csv_path,output_path) 98 | -------------------------------------------------------------------------------- /img/Average_vs_Python.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isLinXu/model-metrics-plot/aac37d36937f9a04cce5d5498262deb88f8f42bb/img/Average_vs_Python.png -------------------------------------------------------------------------------- /img/JavaScript_vs_ C++.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isLinXu/model-metrics-plot/aac37d36937f9a04cce5d5498262deb88f8f42bb/img/JavaScript_vs_ C++.png -------------------------------------------------------------------------------- /img/bar_chart_plot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isLinXu/model-metrics-plot/aac37d36937f9a04cce5d5498262deb88f8f42bb/img/bar_chart_plot.jpg -------------------------------------------------------------------------------- /img/data_csv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isLinXu/model-metrics-plot/aac37d36937f9a04cce5d5498262deb88f8f42bb/img/data_csv.png -------------------------------------------------------------------------------- /img/mllm_chart_acc1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isLinXu/model-metrics-plot/aac37d36937f9a04cce5d5498262deb88f8f42bb/img/mllm_chart_acc1.png -------------------------------------------------------------------------------- /img/paddle_plot_metrics.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isLinXu/model-metrics-plot/aac37d36937f9a04cce5d5498262deb88f8f42bb/img/paddle_plot_metrics.jpg -------------------------------------------------------------------------------- /img/plot_metrics.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isLinXu/model-metrics-plot/aac37d36937f9a04cce5d5498262deb88f8f42bb/img/plot_metrics.jpg -------------------------------------------------------------------------------- /img/plot_mult_chart.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isLinXu/model-metrics-plot/aac37d36937f9a04cce5d5498262deb88f8f42bb/img/plot_mult_chart.jpg -------------------------------------------------------------------------------- /img/plot_mult_code_chart.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isLinXu/model-metrics-plot/aac37d36937f9a04cce5d5498262deb88f8f42bb/img/plot_mult_code_chart.jpg -------------------------------------------------------------------------------- /img/project_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isLinXu/model-metrics-plot/aac37d36937f9a04cce5d5498262deb88f8f42bb/img/project_logo.png -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | from plots.bar_chart_plot import bar_chart_plot 2 | from plots.line_metrics_plots import plot_metrics 3 | from plots.mult_chart_plot import plot_chart 4 | from plots.leida_chart_plot import plot_evaluation_chart 5 | from utils.dataloader import pd_read_csv 6 | 7 | import argparse 8 | 9 | 10 | def parse_opt(known=False): 11 | parser = argparse.ArgumentParser(description="Quick use model-metrics-plot") 12 | parser.add_argument('-c', '--csv', default='data/Pytorch_models_data.csv', help="csv path") 13 | parser.add_argument('-n', '--fig_path', default='output/plot_metrics.jpg', help="figure path") 14 | parser.add_argument('-p', '--plot_type', default='line', help="i.e line, bar, scatter") 15 | parser.add_argument('-t', '--title_name', default='MS COCO Object Detection', help="title name") 16 | parser.add_argument('-x', '--xlabel_name', default='PyTorch FP16 RTX3080(ms/img)', help="xlabel name") 17 | parser.add_argument('-y', '--ylabel_name', default='COCO Mask AP val', help="ylabel name") 18 | parser.add_argument('-g', '--is_grid', default=False, help="is grid") 19 | parser.add_argument('-f', '--font_size', default=10, help="font_size") 20 | parser.add_argument('-v', '--value_type', default='mAP', help="value type,i.e mAP, FPS, ms") 21 | parser.add_argument('-r', '--colors', default='#0000FF', help="colors") 22 | 23 | return parser.parse_known_args()[0] if known else parser.parse_args() 24 | 25 | 26 | def main(opt): 27 | csv_path = opt.csv 28 | fig_path = opt.fig_path 29 | plot_type = opt.plot_type 30 | title_name = opt.title_name 31 | xlabel_name = opt.xlabel_name 32 | ylabel_name = opt.ylabel_name 33 | is_grid = opt.is_grid 34 | font_size = opt.font_size 35 | value_type = opt.value_type 36 | colors = opt.colors 37 | 38 | # read data 39 | df = pd_read_csv(csv_path) 40 | # plot 41 | if plot_type == 'line': 42 | plot_metrics(df, fig_path, title_name, xlabel_name, ylabel_name, font_size, is_grid) 43 | elif plot_type == 'bar': 44 | bar_chart_plot(df, fig_path, value_type, title_name, xlabel_name, colors, is_grid) 45 | elif plot_type == 'chart': 46 | plot_chart(df, fig_path, is_grid, title_name, font_size) 47 | elif plot_type == 'radar': 48 | plot_evaluation_chart(csv_path, fig_path, font_size) 49 | 50 | if __name__ == '__main__': 51 | opt = parse_opt() 52 | main(opt) 53 | -------------------------------------------------------------------------------- /mmplot/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isLinXu/model-metrics-plot/aac37d36937f9a04cce5d5498262deb88f8f42bb/mmplot/__init__.py -------------------------------------------------------------------------------- /mmplot/core/__init__.py: -------------------------------------------------------------------------------- 1 | from plots.line_metrics_plots import plot_metrics 2 | from utils.dataloader import pd_read_csv 3 | 4 | import argparse 5 | 6 | def parse_opt(known=False): 7 | 8 | parser = argparse.ArgumentParser() 9 | parser = argparse.ArgumentParser(description="Quick use model-metrics-plot") 10 | parser.add_argument('-c', '--csv', default='../data/Pytorch_models_data.csv', help="csv path") 11 | parser.add_argument('-n', '--fig_name', default='plot_metrics.jpg', help="figure name") 12 | parser.add_argument('-t', '--title_name', default='MS COCO Object Detection', help="title_name") 13 | parser.add_argument('-x', '--xlabel_name', default='PyTorch FP16 RTX3080(ms/img)', help="xlabel_name") 14 | parser.add_argument('-y', '--ylabel_name', default='COCO Mask AP val', help="ylabel_name") 15 | parser.add_argument('-f', '--font_size', default=10, help="font_size") 16 | 17 | return parser.parse_known_args()[0] if known else parser.parse_args() 18 | 19 | 20 | 21 | def main(opt): 22 | csv_path = opt.csv 23 | fig_name = opt.fig_name 24 | title_name = opt.title_name 25 | xlabel_name = opt.xlabel_name 26 | ylabel_name = opt.ylabel_name 27 | font_size = opt.font_size 28 | df = pd_read_csv(csv_path) 29 | plot_metrics(df, fig_name, title_name, xlabel_name, ylabel_name, font_size) 30 | 31 | 32 | if __name__ == '__main__': 33 | opt = parse_opt() 34 | main(opt) -------------------------------------------------------------------------------- /mmplot/core/run.py: -------------------------------------------------------------------------------- 1 | 2 | from plots.line_metrics_plots import plot_metrics 3 | from utils.dataloader import pd_read_csv 4 | 5 | import argparse 6 | 7 | def parse_opt(known=False): 8 | 9 | parser = argparse.ArgumentParser() 10 | parser = argparse.ArgumentParser(description="Quick use model-metrics-plot") 11 | parser.add_argument('-c', '--csv', default='../data/Pytorch_models_data.csv', help="csv path") 12 | parser.add_argument('-n', '--fig_name', default='plot_metrics.jpg', help="figure name") 13 | parser.add_argument('-t', '--title_name', default='MS COCO Object Detection', help="title_name") 14 | parser.add_argument('-x', '--xlabel_name', default='PyTorch FP16 RTX3080(ms/img)', help="xlabel_name") 15 | parser.add_argument('-y', '--ylabel_name', default='COCO Mask AP val', help="ylabel_name") 16 | parser.add_argument('-f', '--font_size', default=10, help="font_size") 17 | 18 | return parser.parse_known_args()[0] if known else parser.parse_args() 19 | 20 | 21 | 22 | def plots(opt): 23 | csv_path = opt.csv 24 | fig_name = opt.fig_name 25 | title_name = opt.title_name 26 | xlabel_name = opt.xlabel_name 27 | ylabel_name = opt.ylabel_name 28 | font_size = opt.font_size 29 | df = pd_read_csv(csv_path) 30 | plot_metrics(df, fig_name, title_name, xlabel_name, ylabel_name, font_size) 31 | 32 | 33 | if __name__ == '__main__': 34 | opt = parse_opt() 35 | plots(opt) 36 | -------------------------------------------------------------------------------- /mmplot/data/MMYOLO_model_data.csv: -------------------------------------------------------------------------------- 1 | model,branch,ms,fps,mAP 2 | YOLOv5,n,-1,-1,28 3 | YOLOv5,s,-1,-1,37.7 4 | YOLOv5,m,-1,-1,45.3 5 | YOLOv5,l,-1,-1,48.8 6 | YOLOv6,n,-1,-1,36.2 7 | YOLOv6,t,-1,-1,41.0 8 | YOLOv6,s,-1,-1,44.0 9 | YOLOv6,m,-1,-1,48.4 10 | YOLOv6,l,-1,-1,51.0 11 | YOLOv7,tiny,-1,-1,37.5 12 | YOLOv7,l,-1,-1,50.9 13 | YOLOv8,x,-1,-1,52.8 14 | PP-YOLOE,s,-1,-1,43.5 15 | PP-YOLOE,m,-1,-1,49.5 16 | PP-YOLOE,l,-1,-1,52.6 17 | PP-YOLOE,x,-1,-1,54.2 18 | -------------------------------------------------------------------------------- /mmplot/data/PaddleYOLO_model_data.csv: -------------------------------------------------------------------------------- 1 | model,branch,ms,fps,mAP 2 | YOLOv5,n,2.6,-1,28 3 | YOLOv5,s,3.2,-1,37.6 4 | YOLOv5,m,5.2,-1,45.4 5 | YOLOv5,l,7.9,-1,48.9 6 | YOLOv5,x,13.7,-1,50.6 7 | YOLOv6,n,1.3,-1,36.1 8 | YOLOv6,t,2.1,-1,40.7 9 | YOLOv6,s,2.6,-1,43.4 10 | YOLOv6,m,5.0 ,-1,49.0 11 | YOLOv6,l,7.9,-1,51.0 12 | YOLOv6,l-silu,9.6,-1,51.7 13 | YOLOv7,l,7.4,-1,51.0 14 | YOLOv7,x,12.2,-1,53.0 15 | YOLOv8,n,2.4,-1,37.3 16 | YOLOv8,s,3.4,-1,44.9 17 | YOLOv8,m,6.5,-1,50.2 18 | YOLOv8,l,10.0 ,-1,52.8 19 | YOLOv8,x,15.1,-1,53.8 20 | YOLOX,s,3.0 ,-1,40.4 21 | YOLOX,m,5.8,-1,46.9 22 | YOLOX,l,9.3,-1,50.1 23 | YOLOX,x,16.6,-1,51.8 24 | PP-YOLOE,s,2.9 ,-1,43.0 25 | PP-YOLOE,m,6.0 ,-1,49.0 26 | PP-YOLOE,l,8.7,-1,51.4 27 | PP-YOLOE,x,14.9,-1,52.3 28 | -------------------------------------------------------------------------------- /mmplot/data/Pytorch_model_data.csv: -------------------------------------------------------------------------------- 1 | model,branch,ms,fps,mAP 2 | YOLOv5,YOLOv5n,6.3,-1,28 3 | YOLOv5,YOLOv5s,6.4,-1,37.4 4 | YOLOv5,YOLOv5m,8.2,-1,45.4 5 | YOLOv5,YOLOv5l,10.1,-1,49 6 | YOLOv5,YOLOv5x,12.1,-1,50.7 7 | YOLOv6,YOLOv6-N,-1,779,37.5 8 | YOLOv6,YOLOv6-S,-1,339,45 9 | YOLOv6,YOLOv6-M,-1,175,50 10 | YOLOv6,YOLOv6-L,-1,98,52.8 11 | YOLOv6-6,YOLOv6-N6,-1,228,44.9 12 | YOLOv6-6,YOLOv6-S6,-1,98,50.3 13 | YOLOv6-6,YOLOv6-M6,-1,47,55.2 14 | YOLOv6-6,YOLOv6-L6,-1,26,57.2 15 | YOLOv7,YOLOv7,-1,161,51.4 16 | YOLOv7,YOLOv7-X,-1,114,53.1 17 | YOLOv7,YOLOv7-W6,-1,84,54.9 18 | YOLOv7,YOLOv7-E6,-1,56,56 19 | YOLOv7,YOLOv7-D6,-1,44,56.6 20 | YOLOv7,YOLOv7-E6E,-1,36,56.8 21 | YOLOv8,YOLOv8n,5.6,-1,37.3 22 | YOLOv8,YOLOv8s,5.7,-1,44.9 23 | YOLOv8,YOLOv8m,8.3,-1,50.2 24 | YOLOv8,YOLOv8l,13.1,-1,52.9 25 | YOLOv8,YOLOv8x,20.4,-1,53.9 26 | YOLOv8-seg,YOLOv8n-seg,11.3,-1,30.7 27 | YOLOv8-seg,YOLOv8s-seg,11.4,-1,37 28 | YOLOv8-seg,YOLOv8m-seg,15.3,-1,40.6 29 | YOLOv8-seg,YOLOv8l-seg,16.8,-1,42.5 30 | YOLOv8-seg,YOLOv8x-seg,23.8,-1,43.2 31 | -------------------------------------------------------------------------------- /mmplot/data/Pytorch_models_data.csv: -------------------------------------------------------------------------------- 1 | model,branch,ms,fps,mAP 2 | YOLOv5,n,6.3,-1,28 3 | YOLOv5,s,6.4,-1,37.4 4 | YOLOv5,m,8.2,-1,45.4 5 | YOLOv5,l,10.1,-1,49 6 | YOLOv5,x,12.1,-1,50.7 7 | YOLOv6,N,-1,779,37.5 8 | YOLOv6,S,-1,339,45 9 | YOLOv6,M,-1,175,50 10 | YOLOv6,L,-1,98,52.8 11 | YOLOv6-2.0,N6,-1,228,44.9 12 | YOLOv6-2.0,S6,-1,98,50.3 13 | YOLOv6-2.0,M6,-1,47,55.2 14 | YOLOv6-2.0,L6,-1,26,57.2 15 | YOLOv7,L,12.2,-1,51.0 16 | YOLOv7,X,19.4,-1,53.0 17 | YOLOv8,n,5.6,-1,37.3 18 | YOLOv8,s,5.7,-1,44.9 19 | YOLOv8,m,8.3,-1,50.2 20 | YOLOv8,l,13.1,-1,52.9 21 | YOLOv8,x,20.4,-1,53.9 22 | YOLOv8-seg,n-seg,11.3,-1,30.7 23 | YOLOv8-seg,s-seg,11.4,-1,37 24 | YOLOv8-seg,m-seg,15.3,-1,40.6 25 | YOLOv8-seg,l-seg,16.8,-1,42.5 26 | YOLOv8-seg,x-seg,23.8,-1,43.2 27 | -------------------------------------------------------------------------------- /mmplot/data/model_data.csv: -------------------------------------------------------------------------------- 1 | model,branch,ms,fps,mAP 2 | YOLOv5,YOLOv5n,6.3,,28 3 | YOLOv5,YOLOv5s,6.4,,37.4 4 | YOLOv5,YOLOv5m,8.2,,45.4 5 | YOLOv5,YOLOv5l,10.1,,49 6 | YOLOv5,YOLOv5x,12.1,,50.7 7 | YOLOv6,YOLOv6-N,,779,37.5 8 | YOLOv6,YOLOv6-S,,339,45 9 | YOLOv6,YOLOv6-M,,175,47 10 | YOLOv6,YOLOv6-L,,98,26 11 | YOLOv6-6,YOLOv6-N6,,228,44.9 12 | YOLOv6-6,YOLOv6-S6,,98,50.3 13 | YOLOv6-6,YOLOv6-M6,,47,55.2 14 | YOLOv6-6,YOLOv6-L6,,26,57.2 15 | YOLOv7,YOLOv7,,161,51.4 16 | YOLOv7,YOLOv7-X,,114,53.1 17 | YOLOv7,YOLOv7-W6,,84,54.9 18 | YOLOv7,YOLOv7-E6,,56,56 19 | YOLOv7,YOLOv7-D6,,44,56.6 20 | YOLOv7,YOLOv7-E6E,,36,56.8 21 | YOLOv8,YOLOv8n,5.6,,37.3 22 | YOLOv8,YOLOv8s,5.7,,44.9 23 | YOLOv8,YOLOv8m,8.3,,50.2 24 | YOLOv8,YOLOv8l,13.1,,52.9 25 | YOLOv8,YOLOv8x,20.4,,53.9 26 | YOLOv8-seg,YOLOv8n-seg,11.3,,30.7 27 | YOLOv8-seg,YOLOv8s-seg,11.4,,37.0 28 | YOLOv8-seg,YOLOv8m-seg,15.3,,40.6 29 | YOLOv8-seg,YOLOv8l-seg,16.8,,42.5 30 | YOLOv8-seg,YOLOv8x-seg,23.8,,43.2 31 | -------------------------------------------------------------------------------- /mmplot/plots/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) isLinXu. All Rights Reserved 3 | from .metrics_plots import * 4 | from .bar_chart_plot import * 5 | from .mult_chart_plot import * 6 | 7 | __all__ = ["plot_metrics"] 8 | -------------------------------------------------------------------------------- /mmplot/plots/bar_chart_plot.py: -------------------------------------------------------------------------------- 1 | import random as random 2 | 3 | import matplotlib.pyplot as plt 4 | import matplotlib 5 | 6 | from utils import pd_read_csv 7 | 8 | 9 | def bar_chart_plot(df, fig_path, value_type='mAP', title_name="MS COCO Object Detection", xlabel_name="COCO mAP(%)", 10 | color='#0000FF', is_grid=True): 11 | value_list = [] 12 | name_list = [] 13 | ms_list = [] 14 | fps_list = [] 15 | map_list = df['mAP'] 16 | for i in range(0, len(map_list)): 17 | label = df[df['mAP'] == map_list[i]]['branch'].values 18 | ms = df[df['mAP'] == map_list[i]]['ms'].values 19 | fps = df[df['mAP'] == map_list[i]]['fps'].values 20 | model = df[df['mAP'] == map_list[i]]['model'].values 21 | # print('ms', ms, 'label', label, 'fps', fps, 'model', model) 22 | if map_list[i] != -1: 23 | name = model + label 24 | name_list.append(name) 25 | if value_type == 'mAP': 26 | value_list = map_list 27 | elif value_type == 'ms': 28 | value_list.append(float(ms)) 29 | elif value_type == 'fps': 30 | value_list.append(float(fps)) 31 | 32 | plt.barh(range(len(value_list)), value_list, height=0.5, color=color, alpha=0.8) # 从下往上画 33 | plt.yticks(range(len(value_list)), name_list, size='small') 34 | plt.xlim(0, 100) 35 | plt.xlabel(xlabel_name) 36 | plt.title(title_name) 37 | for x, y in enumerate(value_list): 38 | plt.text(y + 0.2, x - 0.1, '%s' % y) 39 | 40 | # grid 41 | if is_grid: 42 | plt.grid() 43 | 44 | # save 45 | plt.savefig(fig_path, dpi=1080) 46 | 47 | # imshow 48 | plt.show() 49 | 50 | 51 | if __name__ == '__main__': 52 | csv_path = '../data/MMYOLO_model_data.csv' 53 | fig_path = '../output/bar_chart_plot.jpg' 54 | value_type = 'mAP' 55 | df = pd_read_csv(csv_path) 56 | bar_chart_plot(df, fig_path, value_type) 57 | -------------------------------------------------------------------------------- /mmplot/plots/line_metrics_plots.py: -------------------------------------------------------------------------------- 1 | import math 2 | import matplotlib.pyplot as plt 3 | from matplotlib.pyplot import MultipleLocator 4 | 5 | from utils.dataloader import pd_read_csv, fps_to_ms 6 | 7 | 8 | def is_nan(x): 9 | return type(x) is float and math.isnan(float(x)) 10 | 11 | 12 | def plot_metrics(df, fig_path, title_name='MS COCO Object Detection', 13 | xlabel_name='PyTorch FP16 RTX3080(ms/img)', 14 | ylabel_name='COCO Mask AP val', font_size=10, is_grid=True): 15 | 16 | model_list = df['model'].unique() 17 | for i in range(0, len(model_list)): 18 | label_list = df[df['model'] == model_list[i]]['branch'].tolist() 19 | ms_list = df[df['model'] == model_list[i]]['ms'].values 20 | fps_list = df[df['model'] == model_list[i]]['fps'].values 21 | map_list = df[df['model'] == model_list[i]]['mAP'].values 22 | maker_list = df[df['model'] == model_list[i]]['maker'].values 23 | 24 | y_list = map_list 25 | t_list = [] 26 | 27 | if fps_list[0] == -1: 28 | x_list = ms_list 29 | else: 30 | for j in fps_list: 31 | j = fps_to_ms(j) 32 | t_list.append(j) 33 | x_list = t_list 34 | 35 | 36 | plt.plot(x_list, y_list, marker=maker_list[0], markersize=font_size) 37 | 38 | plt.title(title_name) 39 | plt.xlabel(xlabel_name) 40 | plt.ylabel(ylabel_name) 41 | 42 | 43 | for ms, map, label in zip(x_list, y_list, label_list): 44 | plt.text(ms, map, label, ha='center', va='bottom', fontsize=font_size) 45 | 46 | # grid 47 | if is_grid: 48 | plt.grid() 49 | # legend 50 | plt.legend(model_list, loc='lower right') 51 | # save 52 | plt.savefig(fig_path, dpi=1080) 53 | # show 54 | plt.show() 55 | 56 | 57 | if __name__ == '__main__': 58 | csv_path = '../data/Pytorch_models_data.csv' 59 | fig_path = 'plot_metrics.jpg' 60 | df = pd_read_csv(csv_path) 61 | plot_metrics(df, fig_path) 62 | -------------------------------------------------------------------------------- /mmplot/plots/metrics_plots.py: -------------------------------------------------------------------------------- 1 | import math 2 | import matplotlib.pyplot as plt 3 | 4 | from utils.dataloader import pd_read_csv, fps_to_ms 5 | 6 | 7 | def is_nan(x): 8 | return type(x) is float and math.isnan(float(x)) 9 | 10 | 11 | def plot_metrics(df, fig_name, title_name='MS COCO Object Detection', 12 | xlabel_name='PyTorch FP16 RTX3080(ms/img)', 13 | ylabel_name='COCO Mask AP val', font_size=10): 14 | 15 | model_list = df['model'].unique() 16 | 17 | for i in range(0, len(model_list)): 18 | label_list = df[df['model'] == model_list[i]]['branch'].tolist() 19 | ms_list = df[df['model'] == model_list[i]]['ms'].values 20 | fps_list = df[df['model'] == model_list[i]]['fps'].values 21 | map_list = df[df['model'] == model_list[i]]['mAP'].values 22 | maker_list = df[df['model'] == model_list[i]]['maker'].values 23 | 24 | y_list = map_list 25 | t_list = [] 26 | 27 | if fps_list[0] == -1: 28 | x_list = ms_list 29 | else: 30 | for j in fps_list: 31 | j = fps_to_ms(j) 32 | t_list.append(j) 33 | x_list = t_list 34 | plt.plot(x_list, y_list, marker=maker_list[0], markersize=font_size) 35 | plt.title(title_name) 36 | plt.xlabel(xlabel_name) 37 | plt.ylabel(ylabel_name) 38 | for ms, map, label in zip(x_list, y_list, label_list): 39 | plt.text(ms, map, label, ha='center', va='bottom', fontsize=font_size) 40 | # legend 41 | plt.legend(model_list, loc='lower right') 42 | 43 | # save 44 | plt.savefig(fig_name, dpi=640) 45 | # show 46 | plt.show() 47 | 48 | 49 | if __name__ == '__main__': 50 | csv_path = 'data/Pytorch_models_data.csv' 51 | fig_name = 'plot_metrics.jpg' 52 | df = pd_read_csv(csv_path) 53 | plot_metrics(df, fig_name) 54 | -------------------------------------------------------------------------------- /mmplot/plots/mult_chart_plot.py: -------------------------------------------------------------------------------- 1 | 2 | import matplotlib.pyplot as plt 3 | import pandas as pd 4 | import numpy as np 5 | 6 | from utils.dataloader import pd_read_csv 7 | 8 | def plot_chart(df,fig_path,is_grid,title_name,font_size): 9 | # 提取数据 10 | categories = list(df.columns[1:]) 11 | values = df.values[:, 1:] 12 | model_labels = df.values[:, 0] 13 | 14 | # 计算角度 15 | angles = np.linspace(0, 2 * np.pi, len(categories), endpoint=False).tolist() 16 | angles += angles[:1] # 闭合多边形 17 | 18 | fig, ax = plt.subplots(figsize=(16, 16), subplot_kw=dict(polar=True)) 19 | 20 | # 设置坐标标签字体大小 21 | plt.xticks(fontsize=font_size) 22 | plt.yticks(fontsize=font_size) 23 | 24 | if is_grid is False: 25 | # 隐藏最外圈的圆 26 | ax.spines['polar'].set_visible(False) 27 | # 隐藏圆形网格线 28 | ax.grid(False) 29 | 30 | # 绘制每一行数据的多边形 31 | for i, row in enumerate(values): 32 | data = np.concatenate((row, [row[0]])) # 闭合多边形 33 | label_name = model_labels[i] 34 | 35 | ax.plot(angles, data, label=label_name) # 绘制多边形 36 | # ax.legend(label_name, fontsize=18) 37 | ax.fill(angles, data, alpha=0.25) # 填充多边形 38 | # 添加图例并设置位置 39 | # ax.legend(bbox_to_anchor=(1, 0), loc='lower right') 40 | 41 | # 设置刻度、标签和标题 42 | ax.set_xticks(angles[:-1]) 43 | # plt.legend(loc="lower left") 44 | 45 | ax.set_xticklabels(categories) 46 | ax.set_title(title_name, fontsize=font_size) 47 | 48 | # 添加图例 49 | ax.legend(bbox_to_anchor=(1.0, 1.1)) 50 | 51 | # 显示图形 52 | plt.show() 53 | 54 | # 保存图形 55 | fig.savefig(fig_path, dpi=300, bbox_inches='tight', transparent=True) 56 | 57 | if __name__ == '__main__': 58 | csv_path = '../../data/llm_eval_data.csv' 59 | fig_path = 'plot_mult_chart.jpg' 60 | is_grid = False 61 | title_name = 'LLM Eval' 62 | plot_type = 'chart' 63 | font_size = 18 64 | df = pd_read_csv(csv_path) 65 | plot_chart(df, fig_path,is_grid,title_name,font_size) -------------------------------------------------------------------------------- /mmplot/utils/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) isLinXu. All Rights Reserved 3 | from .config import * 4 | from .logger import * 5 | from .dataloader import * 6 | 7 | __all__ = ["config", "dataloader", "logger"] 8 | -------------------------------------------------------------------------------- /mmplot/utils/config.py: -------------------------------------------------------------------------------- 1 | 2 | from pathlib import Path 3 | from typing import Dict, Union 4 | 5 | from difflib import get_close_matches 6 | 7 | from omegaconf import DictConfig, OmegaConf 8 | 9 | from utils.logger import LOGGER, colorstr 10 | 11 | # Constants 12 | FILE = Path(__file__).resolve() 13 | ROOT = FILE.parents[1] 14 | DEFAULT_CONFIG = ROOT / "configs/default.yaml" 15 | 16 | 17 | def check_config_mismatch(overrides, cfg): 18 | mismatched = [option for option in overrides if option not in cfg and 'hydra.' not in option] 19 | 20 | for option in mismatched: 21 | LOGGER.info(f"{colorstr(option)} is not a valid key. Similar keys: {get_close_matches(option, cfg, 3, 0.6)}") 22 | if mismatched: 23 | exit() 24 | 25 | def get_config(config: Union[str, DictConfig], overrides: Union[str, Dict] = None): 26 | """ 27 | Load and merge configuration data from a file or dictionary. 28 | 29 | Args: 30 | config (Union[str, DictConfig]): Configuration data in the form of a file name or a DictConfig object. 31 | overrides (Union[str, Dict], optional): Overrides in the form of a file name or a dictionary. Default is None. 32 | 33 | Returns: 34 | OmegaConf.Namespace: Training arguments namespace. 35 | """ 36 | if overrides is None: 37 | overrides = {} 38 | if isinstance(config, (str, Path)): 39 | config = OmegaConf.load(config) 40 | elif isinstance(config, Dict): 41 | config = OmegaConf.create(config) 42 | # override 43 | if isinstance(overrides, str): 44 | overrides = OmegaConf.load(overrides) 45 | elif isinstance(overrides, Dict): 46 | overrides = OmegaConf.create(overrides) 47 | 48 | check_config_mismatch(dict(overrides).keys(), dict(config).keys()) 49 | 50 | return OmegaConf.merge(config, overrides) -------------------------------------------------------------------------------- /mmplot/utils/dataloader.py: -------------------------------------------------------------------------------- 1 | 2 | import math 3 | import pandas 4 | def pd_read_csv(csv_path): 5 | 6 | df = pandas.read_csv(csv_path) 7 | # print(df) 8 | return df 9 | 10 | def fps_to_ms(fps: int) -> int: 11 | ''' 12 | Convert FPS to a millisecond interval. 13 | Args: 14 | fps: Input FPS as integer. 15 | Returns: 16 | Interval in milliseconds as integer number. 17 | ''' 18 | return math.floor((1 / fps) * 1000) 19 | 20 | if __name__ == '__main__': 21 | csv_path = '/data/model_data.csv' 22 | df = pd_read_csv(csv_path) 23 | print(df.shape) # 返回df的行数和列数 24 | print(df.shape[0]) # 返回df的行数 25 | print(df.shape[1]) # 返回df的列数 26 | 27 | -------------------------------------------------------------------------------- /mmplot/utils/logger.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | import os 4 | import logging 5 | 6 | LOGGING_NAME = 'metrics_plots' 7 | def set_logging(name=LOGGING_NAME, verbose=True): 8 | # sets up logging for the given name 9 | rank = int(os.getenv('RANK', -1)) # rank in world for Multi-GPU trainings 10 | level = logging.INFO if verbose and rank in {-1, 0} else logging.ERROR 11 | logging.config.dictConfig({ 12 | "version": 1, 13 | "disable_existing_loggers": False, 14 | "formatters": { 15 | name: { 16 | "format": "%(message)s"}}, 17 | "handlers": { 18 | name: { 19 | "class": "logging.StreamHandler", 20 | "formatter": name, 21 | "level": level,}}, 22 | "loggers": { 23 | name: { 24 | "level": level, 25 | "handlers": [name], 26 | "propagate": False,}}}) 27 | 28 | 29 | 30 | # set_logging(LOGGING_NAME) # run before defining LOGGER 31 | LOGGER = logging.getLogger(LOGGING_NAME) # define globally (used in train.py, val.py, detect.py, etc.) 32 | 33 | def colorstr(*input): 34 | # Colors a string https://en.wikipedia.org/wiki/ANSI_escape_code, i.e. colorstr('blue', 'hello world') 35 | *args, string = input if len(input) > 1 else ("blue", "bold", input[0]) # color arguments, string 36 | colors = { 37 | "black": "\033[30m", # basic colors 38 | "red": "\033[31m", 39 | "green": "\033[32m", 40 | "yellow": "\033[33m", 41 | "blue": "\033[34m", 42 | "magenta": "\033[35m", 43 | "cyan": "\033[36m", 44 | "white": "\033[37m", 45 | "bright_black": "\033[90m", # bright colors 46 | "bright_red": "\033[91m", 47 | "bright_green": "\033[92m", 48 | "bright_yellow": "\033[93m", 49 | "bright_blue": "\033[94m", 50 | "bright_magenta": "\033[95m", 51 | "bright_cyan": "\033[96m", 52 | "bright_white": "\033[97m", 53 | "end": "\033[0m", # misc 54 | "bold": "\033[1m", 55 | "underline": "\033[4m",} 56 | return "".join(colors[x] for x in args) + f"{string}" + colors["end"] 57 | 58 | -------------------------------------------------------------------------------- /mmplot/version.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) isLinXu. All rights reserved. 2 | 3 | __version__ = "0.1.7" 4 | short_version = __version__ 5 | 6 | 7 | def parse_version_info(version_str): 8 | version_info = [] 9 | for x in version_str.split("."): 10 | if x.isdigit(): 11 | version_info.append(int(x)) 12 | elif x.find("rc") != -1: 13 | patch_version = x.split("rc") 14 | version_info.append(int(patch_version[0])) 15 | version_info.append(f"rc{patch_version[1]}") 16 | return tuple(version_info) 17 | 18 | 19 | version_info = parse_version_info(__version__) -------------------------------------------------------------------------------- /mmplot_test.py: -------------------------------------------------------------------------------- 1 | 2 | from mmplot.core.run import plots 3 | import mmplot.utils 4 | 5 | 6 | import argparse 7 | def parse_opt(known=False): 8 | 9 | parser = argparse.ArgumentParser() 10 | parser = argparse.ArgumentParser(description="Quick use model-metrics-plot") 11 | parser.add_argument('-c', '--csv', default='data/PaddleYOLO_model_data.csv', help="csv path") 12 | parser.add_argument('-n', '--fig_name', default='plot_metrics.jpg', help="figure name") 13 | parser.add_argument('-t', '--title_name', default='MS COCO Object Detection', help="title_name") 14 | parser.add_argument('-x', '--xlabel_name', default='PyTorch FP16 RTX3080(ms/img)', help="xlabel_name") 15 | parser.add_argument('-y', '--ylabel_name', default='COCO Mask AP val', help="ylabel_name") 16 | parser.add_argument('-f', '--font_size', default=10, help="font_size") 17 | 18 | return parser.parse_known_args()[0] if known else parser.parse_args() 19 | 20 | 21 | if __name__ == '__main__': 22 | # run() 23 | opt = parse_opt() 24 | plots(opt) -------------------------------------------------------------------------------- /output/bar_chart_plot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isLinXu/model-metrics-plot/aac37d36937f9a04cce5d5498262deb88f8f42bb/output/bar_chart_plot.jpg -------------------------------------------------------------------------------- /output/plot_metrics.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isLinXu/model-metrics-plot/aac37d36937f9a04cce5d5498262deb88f8f42bb/output/plot_metrics.jpg -------------------------------------------------------------------------------- /plots/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) isLinXu. All Rights Reserved 3 | from .line_metrics_plots import * 4 | from .bar_chart_plot import * 5 | from .mult_chart_plot import * 6 | __all__ = ["plot_metrics"] 7 | -------------------------------------------------------------------------------- /plots/bar_chart_plot.py: -------------------------------------------------------------------------------- 1 | import random as random 2 | import pandas as pd 3 | import matplotlib.pyplot as plt 4 | import matplotlib 5 | 6 | from utils import pd_read_csv 7 | 8 | def bar_chart(data_file, x_col, y_col): 9 | """ 10 | 绘制柱状图 11 | 12 | Args: 13 | data_file: str, csv 文件路径 14 | x_col: str, 横坐标列名 15 | y_col: str, 纵坐标列名 16 | """ 17 | # 读取 csv 文件 18 | df = pd.read_csv(data_file) 19 | 20 | # 获取数据 21 | x = df[x_col] 22 | y = df[y_col] 23 | 24 | # 绘制柱状图 25 | plt.bar(x, y) 26 | 27 | # 设置图表标题和横纵坐标标签 28 | plt.title('{} vs {}'.format(x_col, y_col)) 29 | plt.xlabel(x_col) 30 | plt.ylabel(y_col) 31 | 32 | # 显示图表 33 | plt.show() 34 | 35 | 36 | 37 | def bar_chart_plot(df, fig_path, value_type='mAP', title_name="MS COCO Object Detection", xlabel_name="COCO mAP(%)", 38 | color='#0000FF', is_grid=True): 39 | value_list = [] 40 | name_list = [] 41 | ms_list = [] 42 | fps_list = [] 43 | map_list = df['mAP'] 44 | for i in range(0, len(map_list)): 45 | label = df[df['mAP'] == map_list[i]]['branch'].values 46 | ms = df[df['mAP'] == map_list[i]]['ms'].values 47 | fps = df[df['mAP'] == map_list[i]]['fps'].values 48 | model = df[df['mAP'] == map_list[i]]['model'].values 49 | # print('ms', ms, 'label', label, 'fps', fps, 'model', model) 50 | if map_list[i] != -1: 51 | name = model + label 52 | name_list.append(name) 53 | if value_type == 'mAP': 54 | value_list = map_list 55 | elif value_type == 'ms': 56 | value_list.append(float(ms)) 57 | elif value_type == 'fps': 58 | value_list.append(float(fps)) 59 | 60 | plt.barh(range(len(value_list)), value_list, height=0.5, color=color, alpha=0.8) # 从下往上画 61 | plt.yticks(range(len(value_list)), name_list, size='small') 62 | plt.xlim(0, 100) 63 | plt.xlabel(xlabel_name) 64 | plt.title(title_name) 65 | for x, y in enumerate(value_list): 66 | plt.text(y + 0.2, x - 0.1, '%s' % y) 67 | 68 | # grid 69 | if is_grid: 70 | plt.grid() 71 | 72 | # save 73 | plt.savefig(fig_path, dpi=1080) 74 | 75 | # imshow 76 | plt.show() 77 | 78 | 79 | if __name__ == '__main__': 80 | csv_path = '../data/MMYOLO_model_data.csv' 81 | fig_path = '../output/bar_chart_plot.jpg' 82 | value_type = 'mAP' 83 | df = pd_read_csv(csv_path) 84 | bar_chart_plot(df, fig_path, value_type) 85 | 86 | # 示例:绘制 'Metric' 列和 'Java' 列的柱状图 87 | bar_chart('../data/llm_code_eval.csv', 'Metric', 'Java') 88 | -------------------------------------------------------------------------------- /plots/bar_metric_plot.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import pandas as pd 3 | 4 | def bar_chart(data_file, x_col, y_col): 5 | """ 6 | 绘制柱状图 7 | 8 | Args: 9 | data_file: str, csv 文件路径 10 | x_col: str, 横坐标列名 11 | y_col: str, 纵坐标列名 12 | """ 13 | # 读取 csv 文件 14 | df = pd.read_csv(data_file) 15 | 16 | # 获取数据 17 | x = df[x_col] 18 | y = df[y_col] 19 | 20 | # 绘制柱状图 21 | plt.bar(x, y) 22 | 23 | # 设置图表标题和横纵坐标标签 24 | plt.title('{} vs {}'.format(x_col, y_col)) 25 | plt.xlabel(x_col) 26 | plt.ylabel(y_col) 27 | 28 | # 显示图表 29 | plt.show() 30 | 31 | # 示例:绘制 'Metric' 列和 'Java' 列的柱状图 32 | bar_chart('../data/llm_code_eval.csv', 'Metric', 'Java') -------------------------------------------------------------------------------- /plots/data_plot.py: -------------------------------------------------------------------------------- 1 | 2 | import pandas as pd 3 | import numpy as np 4 | import matplotlib.pyplot as plt 5 | import seaborn as sns 6 | import networkx as nx 7 | 8 | # 读取 csv 文件 9 | df = pd.read_csv('../data/data1.csv') 10 | 11 | # 饼图 12 | plt.pie(df['value'], labels=df['category'], autopct='%1.1f%%') 13 | plt.title('Pie Chart') 14 | plt.show() 15 | 16 | # 条形图 17 | sns.barplot(x='value', y='category', data=df) 18 | plt.title('Bar Chart') 19 | plt.show() 20 | 21 | # 区域图 22 | sns.lineplot(x='date', y='value', hue='category', data=df) 23 | plt.fill_between(df['date'], df['value'], alpha=0.2) 24 | plt.title('Area Chart') 25 | plt.show() 26 | 27 | # 树状图 28 | G = nx.DiGraph() 29 | G.add_edges_from(df[['parent', 'child']].values) 30 | pos = nx.spring_layout(G) 31 | nx.draw_networkx(G, pos) 32 | nx.draw_networkx_labels(G, pos) 33 | plt.title('Tree Chart') 34 | plt.show() 35 | 36 | # 网络图 37 | G = nx.karate_club_graph() 38 | pos = nx.spring_layout(G) 39 | nx.draw_networkx(G, pos) 40 | plt.title('Network Chart') 41 | plt.show() 42 | 43 | # 密度图 44 | sns.kdeplot(df['value'], fill=True) 45 | plt.title('Density Chart') 46 | plt.show() 47 | 48 | # 箱形图 49 | sns.boxplot(x='category', y='value', data=df) 50 | plt.title('Box Chart') 51 | plt.show() 52 | 53 | # 热图 54 | pivot_table = df.pivot_table(index='category', columns='date', values='value') 55 | sns.heatmap(pivot_table, cmap='YlGnBu') 56 | plt.title('Heatmap') 57 | plt.show() -------------------------------------------------------------------------------- /plots/leida_chart_plot.py: -------------------------------------------------------------------------------- 1 | # author: isLinXu 2 | import matplotlib.pyplot as plt 3 | import pandas as pd 4 | import numpy as np 5 | from adjustText import adjust_text 6 | 7 | # from utils.colors import colors_dark, colors_light, colors_classic, colors_common, colors_dark_private, \ 8 | # colors_common_private, colors_hex 9 | # from utils.fonts import font_new_roman 10 | 11 | def plot_evaluation_chart(csv_path, output_path='evaluation_chart.png', figsize=(16, 16), style=None): 12 | ''' 13 | 绘制雷达图 14 | Args: 15 | csv_path: csv文件路径 16 | output_path: 图片保存路径 17 | figsize: 图片大小 18 | style: 图表样式 19 | 20 | Returns: 21 | 22 | ''' 23 | if style is None: 24 | style = { 25 | 'font_family': 'Times New Roman', 26 | 'font_size': 25, 27 | 'legend_font_size': 20, 28 | 'colors': ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf', 29 | 'darkblue', 'darkorange', 'darkgreen', 'darkred', 'darkviolet', 'saddlebrown', 'deeppink', 'dimgray', 'darkolivegreen', 'darkcyan'] 30 | } 31 | 32 | # 设置全局字体 33 | plt.rcParams['font.family'] = style['font_family'] 34 | 35 | # 读取CSV文件并提取数据 36 | data_frame = pd.read_csv(csv_path) 37 | categories = list(data_frame.columns[1:]) 38 | values = data_frame.values[:, 1:] 39 | model_labels = data_frame.values[:, 0] 40 | 41 | # 计算角度并闭合多边形 42 | angles = np.linspace(0, 2 * np.pi, len(categories), endpoint=False).tolist() 43 | angles += angles[:1] 44 | 45 | # 创建极坐标图并设置大小 46 | # fig, ax = plt.subplots(figsize=figsize, subplot_kw=dict(polar=True)) 47 | fig, ax = plt.subplots(figsize=(16, 16), subplot_kw=dict(polar=True)) 48 | # 设置坐标标签字体大小 49 | plt.xticks(fontsize=style['font_size']) 50 | plt.yticks(fontsize=style['font_size']) 51 | 52 | # 隐藏最外圈的圆 53 | ax.spines['polar'].set_visible(False) 54 | 55 | # 绘制每一行数据的多边形 56 | texts = [] 57 | for i, row in enumerate(values): 58 | cr = style['colors'][i % len(style['colors'])] 59 | data = np.concatenate((row, [row[0]])) # 闭合多边形 60 | label_name = model_labels[i] 61 | ax.fill(angles, data, alpha=0.25, color=cr) # 填充多边形 62 | ax.plot(angles, data, label=label_name, linewidth=2.0, color=cr) # 绘制多边形 63 | 64 | # 添加数据点上的文本 65 | for j, value in enumerate(row): 66 | angle_rad = angles[j] 67 | if angle_rad == 0: 68 | ha, distance = 'center', 10 69 | elif 0 < angle_rad < np.pi: 70 | ha, distance = 'left', 1 71 | elif angle_rad == np.pi: 72 | ha, distance = 'center', 10 73 | else: 74 | ha, distance = 'right', 1 75 | text = ax.text(angle_rad, value + distance, f'{value:.2f}', size=style['font_size'], color=cr, horizontalalignment=ha) 76 | texts.append(text) 77 | 78 | # 调整文本位置以避免重叠 79 | adjust_text(texts, expand_text=(1.05, 1.2), expand_points=(1.05, 1.2), force_text=(0.1, 0.25), force_points=(0.2, 0.5), ax=ax) 80 | 81 | # 设置刻度、标签和标题 82 | ax.set_xticks(angles[:-1]) 83 | ax.set_xticklabels(categories) 84 | ax.set_yticklabels([]) # 隐藏y轴刻度 85 | 86 | # 设置图例属性 87 | num_models = len(values) 88 | legend = ax.legend(bbox_to_anchor=(0.5, -0.15), loc='lower center', ncol=num_models, prop={'size': style['legend_font_size']}) 89 | for line in legend.get_lines(): 90 | line.set_linewidth(5) 91 | 92 | # 显示并保存图形 93 | plt.show() 94 | fig.savefig(output_path, dpi=300, bbox_inches='tight', transparent=True) 95 | 96 | if __name__ == '__main__': 97 | # csv_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/research/mllm_acc_eval-csv_private_1230.csv' 98 | # output_path = 'chart/evaluation_chart_private_1230.png' 99 | csv_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/research/mllm_acc_eval-csv_private_0128.csv' 100 | output_path = 'chart/evaluation_chart_private_0128.png' 101 | plot_evaluation_chart(csv_path, output_path) 102 | -------------------------------------------------------------------------------- /plots/line_metrics_plots.py: -------------------------------------------------------------------------------- 1 | import math 2 | import matplotlib.pyplot as plt 3 | from matplotlib.pyplot import MultipleLocator 4 | 5 | from utils.dataloader import pd_read_csv, fps_to_ms 6 | 7 | 8 | def is_nan(x): 9 | return type(x) is float and math.isnan(float(x)) 10 | 11 | 12 | def plot_metrics(df, fig_path, title_name='MS COCO Object Detection', 13 | xlabel_name='PyTorch FP16 RTX3080(ms/img)', 14 | ylabel_name='COCO Mask AP val', font_size=10, is_grid=True): 15 | model_list = df['model'].unique() 16 | for i in range(0, len(model_list)): 17 | label_list = df[df['model'] == model_list[i]]['branch'].tolist() 18 | ms_list = df[df['model'] == model_list[i]]['ms'].values 19 | fps_list = df[df['model'] == model_list[i]]['fps'].values 20 | map_list = df[df['model'] == model_list[i]]['mAP'].values 21 | maker_list = df[df['model'] == model_list[i]]['maker'].values 22 | 23 | y_list = map_list 24 | t_list = [] 25 | 26 | if fps_list[0] == -1: 27 | x_list = ms_list 28 | else: 29 | for j in fps_list: 30 | j = fps_to_ms(j) 31 | t_list.append(j) 32 | x_list = t_list 33 | 34 | plt.plot(x_list, y_list, marker=maker_list[0], markersize=font_size) 35 | 36 | plt.title(title_name) 37 | plt.xlabel(xlabel_name) 38 | plt.ylabel(ylabel_name) 39 | 40 | for ms, map, label in zip(x_list, y_list, label_list): 41 | plt.text(ms, map, label, ha='center', va='bottom', fontsize=font_size) 42 | 43 | # grid 44 | if is_grid: 45 | plt.grid() 46 | # legend 47 | plt.legend(model_list, loc='lower right') 48 | # save 49 | plt.savefig(fig_path, dpi=1080) 50 | # show 51 | plt.show() 52 | 53 | 54 | def plot_multiple_line_charts(data, x_column, y_columns, xlabel, ylabel, title, save_fig='result.png'): 55 | # 提取x轴数据 56 | x_data = data[x_column] 57 | 58 | # 绘制多条折线 59 | for y_column in y_columns: 60 | y_data = data[y_column] 61 | plt.plot(x_data, y_data, label=y_column, marker='o') 62 | 63 | # 为x轴和y轴添加标签 64 | plt.xlabel(xlabel) 65 | plt.ylabel(ylabel) 66 | 67 | # 为图形添加标题 68 | plt.title(title) 69 | 70 | # 添加图例 71 | plt.legend() 72 | plt.savefig(save_fig, dpi=1080) 73 | # 显示图形 74 | plt.show() 75 | 76 | 77 | if __name__ == '__main__': 78 | csv_path = '../data/Pytorch_models_data.csv' 79 | fig_path = 'plot_metrics.jpg' 80 | df = pd_read_csv(csv_path) 81 | plot_metrics(df, fig_path) 82 | 83 | # 读取CSV文件 84 | csv_path = "../data/result_cora.csv" 85 | data = pd_read_csv(csv_path) 86 | 87 | # 调用函数绘制多条折线图 88 | plot_multiple_line_charts(data, "LR(%)", ["Random", "HyperNAS-RL", "HyperNAS"], "LR(%)", "Accuracy", "Cora") 89 | -------------------------------------------------------------------------------- /plots/logic_tree_plot.py: -------------------------------------------------------------------------------- 1 | # 2 | # import matplotlib.pyplot as plt 3 | # 4 | # def draw_tree(tree, root_node, x, y, dx, dy, node_style=None, branch_style=None,debug=False): 5 | # ''' 6 | # 绘制逻辑树 7 | # Args: 8 | # tree: dict, 树的结构 9 | # root_node: str, 根节点 10 | # x: float, 根节点的x坐标 11 | # y: float, 根节点的y坐标 12 | # dx: float, x方向的间距 13 | # dy: float, y方向的间距 14 | # node_style: 节点样式 15 | # branch_style: 分支样式 16 | # 17 | # Returns: 18 | # 19 | # ''' 20 | # def plot_node(node, x, y, dx, dy, ax): 21 | # ax.text(x, y, node, ha='center', va='center', bbox=node_style) 22 | # 23 | # def plot_branch(node, children, x, y, dx, dy, ax): 24 | # if len(children) == 0: 25 | # return 26 | # dx_child = dx / len(children) 27 | # x_left = x - dx_child * (len(children) - 1) / 2 28 | # for child in children: 29 | # ax.plot([x, x_left], [y, y - dy], **branch_style) 30 | # plot_node(child, x_left, y - dy, dx, dy, ax) 31 | # plot_branch(child, tree[child], x_left, y - dy, dx_child, dy, ax) 32 | # x_left += dx_child 33 | # 34 | # fig, ax = plt.subplots() 35 | # ax.set_xlim(0, 10) 36 | # ax.set_ylim(0, 10) 37 | # 38 | # plot_node(root_node, x, y, dx, dy, ax) 39 | # plot_branch(root_node, tree[root_node], x, y, dx, dy, ax) 40 | # 41 | # if debug: 42 | # ax.axis('off') 43 | # plt.show() 44 | # 45 | # if __name__ == '__main__': 46 | # # 定义分支树 47 | # tree = { 48 | # 'A': ['B', 'C'], 49 | # 'B': ['D', 'E'], 50 | # 'C': ['F', 'G'], 51 | # 'D': ['H', 'I'], 52 | # 'E': [], 53 | # 'F': [], 54 | # 'G': [], 55 | # 'H': [], 56 | # 'I': [] 57 | # } 58 | # # 定义节点样式和分支样式 59 | # node_style = dict(facecolor='white', edgecolor='black', boxstyle='circle') 60 | # branch_style = dict(color='black', linestyle='-') 61 | # 62 | # # 调用 draw_tree 函数绘制分支树 63 | # draw_tree(tree, 'A', 5, 10, 8, 2, node_style, branch_style) 64 | 65 | 66 | import json 67 | import random 68 | import matplotlib.pyplot as plt 69 | 70 | 71 | def random_color(): 72 | return (random.random(), random.random(), random.random()) 73 | 74 | 75 | def draw_tree(tree, root_node, x, y, dx, dy, node_style=None, branch_style=None, debug=False): 76 | def plot_node(node, x, y, dx, dy, ax): 77 | ax.text(x, y, node, ha='center', va='center', bbox=node_style) 78 | 79 | def plot_branch(node, children, x, y, dx, dy, ax): 80 | if len(children) == 0: 81 | return 82 | dx_child = dx / len(children) 83 | x_left = x - dx_child * (len(children) - 1) / 2 84 | for child in children: 85 | ax.plot([x, x_left], [y, y - dy], **branch_style) 86 | plot_node(child, x_left, y - dy, dx, dy, ax) 87 | plot_branch(child, tree[child], x_left, y - dy, dx_child, dy, ax) 88 | x_left += dx_child 89 | 90 | fig, ax = plt.subplots() 91 | ax.set_xlim(0, 10) 92 | ax.set_ylim(0, 10) 93 | 94 | plot_node(root_node, x, y, dx, dy, ax) 95 | plot_branch(root_node, tree[root_node], x, y, dx, dy, ax) 96 | 97 | if debug: 98 | ax.axis('off') 99 | plt.show() 100 | 101 | 102 | if __name__ == '__main__': 103 | # 从JSON文件中读取树结构 104 | log_tree_path = '../data/mllm.json' 105 | # log_tree_path = '../data/tree.json' 106 | 107 | with open(log_tree_path, 'r') as f: 108 | tree = json.load(f) 109 | 110 | # color = 'white' 111 | color = None 112 | if color is None: 113 | color = random_color() 114 | 115 | # 定义节点样式和分支样式,颜色为随机颜色 116 | node_style = dict(facecolor=color, edgecolor=color, boxstyle='circle') 117 | branch_style = dict(color=color, linestyle='-') 118 | 119 | # 调用 draw_tree 函数绘制分支树 120 | draw_tree(tree, 'FlanT5xxl', 5, 10, 8, 2, node_style, branch_style) 121 | -------------------------------------------------------------------------------- /plots/model_layer_plt.py: -------------------------------------------------------------------------------- 1 | import re 2 | from graphviz import Digraph 3 | 4 | def extract_structure_info(file_path): 5 | with open(file_path, 'r') as f: 6 | return [line.strip() for line in f if line.startswith(('├─', '│'))] 7 | 8 | def plot_structure_graph(structure_info, file_name): 9 | g = Digraph('G', format='png') 10 | pattern = re.compile(r'├─(.+):(.+)') 11 | parent_layer_name = None 12 | for info in structure_info: 13 | match = pattern.match(info) 14 | if match: 15 | layer_type, layer_name = match.groups() 16 | layer_name = layer_name.strip() 17 | g.node(layer_name, label=f"{layer_type}\n{layer_name}") 18 | if parent_layer_name: 19 | g.edge(parent_layer_name, layer_name) 20 | parent_layer_name = layer_name 21 | 22 | g.render(f"{file_name}_structure_graph", view=True) 23 | 24 | 25 | if __name__ == "__main__": 26 | # file_path = input("请输入文件路径: ") # 通过用户输入获取文件路径 27 | file_path = "/Users/gatilin/PycharmProjects/onnx-easy-tools/vgg16/vgg16.txt" 28 | file_name = file_path.split('/')[-1].split('.')[0] 29 | structure_info = extract_structure_info(file_path) 30 | if structure_info: # 只有在提取到结构信息时才绘制图形 31 | plot_structure_graph(structure_info, file_name) -------------------------------------------------------------------------------- /plots/model_loss_plt.py: -------------------------------------------------------------------------------- 1 | import json 2 | import matplotlib.pyplot as plt 3 | import re 4 | 5 | def plot_loss_curve(file_path): 6 | # 读取文件内容 7 | with open(file_path, 'r') as f: 8 | lines = f.readlines() 9 | 10 | # 使用正则表达式匹配包含'loss'的行并捕获数据 11 | pattern = re.compile(r"\'loss\':\s*(\d+\.\d+),\s*\'grad_norm\':\s*\d+\.\d+,\s*\'learning_rate\':\s*\d+\.\d+,\s*\'epoch\':\s*(\d+\.\d+)") 12 | data = [match.groups() for line in lines for match in [pattern.search(line)] if match] 13 | 14 | # 转换数据为浮点数并提取epoch和loss数据 15 | epochs = [float(d[1]) for d in data] 16 | losses = [float(d[0]) for d in data] 17 | 18 | # 绘制曲线 19 | plt.plot(epochs, losses) 20 | plt.xlabel('Epoch') 21 | plt.ylabel('Loss') 22 | plt.title('Loss Curve') 23 | 24 | # 找到最低点并绘制垂直线 25 | min_index = losses.index(min(losses)) 26 | min_epoch = epochs[min_index] 27 | min_loss = losses[min_index] 28 | plt.axvline(x=min_epoch, color='r', linestyle='--') 29 | 30 | # 绘制水平线并在该线上显示损失值 31 | plt.axhline(y=min_loss, color='r', linestyle='--') 32 | plt.text(min_epoch, min_loss, f'Min Loss: {min_loss:.4f}', va='bottom', ha='left') 33 | 34 | plt.show() 35 | 36 | 37 | def plot_mult_loss_curve(file_paths): 38 | # all_epochs = [] 39 | # all_losses = [] 40 | # num_epochs_per_stage = [] 41 | # 42 | # for file_path in file_paths: 43 | # # 读取文件内容 44 | # with open(file_path, 'r') as f: 45 | # lines = f.readlines() 46 | # 47 | # # 使用正则表达式匹配包含'loss'的行并捕获数据 48 | # pattern = re.compile(r"\'loss\':\s*(\d+\.\d+),\s*\'grad_norm\':\s*\d+\.\d+,\s*\'learning_rate\':\s*\d+\.\d+,\s*\'epoch\':\s*(\d+\.\d+)") 49 | # data = [match.groups() for line in lines for match in [pattern.search(line)] if match] 50 | # 51 | # # 转换数据为浮点数并提取epoch和loss数据 52 | # epochs = [float(d[1]) for d in data] 53 | # losses = [float(d[0]) for d in data] 54 | # 55 | # # 如果不是第一个阶段,将横轴偏移 56 | # if all_epochs: 57 | # epoch_offset = all_epochs[-1] 58 | # epochs = [epoch + epoch_offset for epoch in epochs] 59 | # 60 | # # 将当前阶段的数据添加到总数据中 61 | # all_epochs.extend(epochs) 62 | # all_losses.extend(losses) 63 | # num_epochs_per_stage.append(len(epochs)) 64 | # 65 | # # 绘制曲线 66 | # plt.plot(all_epochs, all_losses) 67 | # plt.xlabel('Epoch') 68 | # plt.ylabel('Loss') 69 | # plt.title('Loss Curve') 70 | # 71 | # # 在各个阶段之间绘制绿色竖直虚线和标记 72 | # for i in range(1, len(file_paths)): 73 | # epoch_boundary = all_epochs[sum(num_epochs_per_stage[:i]) - 1] 74 | # plt.axvline(x=epoch_boundary, color='g', linestyle='--') 75 | # plt.text(epoch_boundary, min(all_losses), f'Stage {i}', va='bottom', ha='left') 76 | # 77 | # plt.show() 78 | all_epochs = [] 79 | all_losses = [] 80 | num_epochs_per_stage = [] 81 | min_points = [] 82 | 83 | for file_path in file_paths: 84 | # 读取文件内容 85 | with open(file_path, 'r') as f: 86 | lines = f.readlines() 87 | 88 | # 使用正则表达式匹配包含'loss'的行并捕获数据 89 | pattern = re.compile( 90 | r"\'loss\':\s*(\d+\.\d+),\s*\'grad_norm\':\s*\d+\.\d+,\s*\'learning_rate\':\s*\d+\.\d+,\s*\'epoch\':\s*(\d+\.\d+)") 91 | data = [match.groups() for line in lines for match in [pattern.search(line)] if match] 92 | 93 | # 转换数据为浮点数并提取epoch和loss数据 94 | epochs = [float(d[1]) for d in data] 95 | losses = [float(d[0]) for d in data] 96 | 97 | # 如果不是第一个阶段,将横轴偏移 98 | if all_epochs: 99 | epoch_offset = all_epochs[-1] 100 | epochs = [epoch + epoch_offset for epoch in epochs] 101 | 102 | # 将当前阶段的数据添加到总数据中 103 | all_epochs.extend(epochs) 104 | all_losses.extend(losses) 105 | num_epochs_per_stage.append(len(epochs)) 106 | 107 | # 找到当前阶段的最低点 108 | min_index = losses.index(min(losses)) 109 | min_epoch = epochs[min_index] 110 | min_loss = losses[min_index] 111 | min_points.append((min_epoch, min_loss)) 112 | 113 | # 绘制曲线 114 | plt.plot(all_epochs, all_losses) 115 | plt.xlabel('Epoch') 116 | plt.ylabel('Loss') 117 | plt.title('Loss Curve') 118 | 119 | # 在各个阶段之间绘制绿色竖直虚线和标记 120 | for i in range(1, len(file_paths)): 121 | epoch_boundary = all_epochs[sum(num_epochs_per_stage[:i]) - 1] 122 | plt.axvline(x=epoch_boundary, color='g', linestyle='--') 123 | plt.text(epoch_boundary, min(all_losses), f'Stage {i}', va='bottom', ha='left') 124 | 125 | # 绘制每个阶段的最低点直线 126 | for min_epoch, min_loss in min_points: 127 | plt.axvline(x=min_epoch, color='r', linestyle='--') 128 | plt.axhline(y=min_loss, color='r', linestyle='--') 129 | plt.text(min_epoch, min_loss, f'Min Loss: {min_loss:.4f}', va='bottom', ha='left') 130 | 131 | plt.show() 132 | 133 | 134 | if __name__ == '__main__': 135 | # 调用函数 136 | # file_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/mgm_2b_loss.txt' 137 | # file_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/mgm_finetune_loss.txt' 138 | # file_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/pretrain.txt' 139 | # file_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/loss/0818/pretrain.log' 140 | # file_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/loss/0818/finetuning.log' 141 | # file_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/loss/0821/pretrain.log' 142 | # file_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/loss/0821/finetuning.log' 143 | # file_path = '/Users/gatilin/PycharmProjects/model-metrics-plot/data/loss/pretrain.log' 144 | # plot_loss_curve(file_path) 145 | 146 | # 调用函数 147 | # file_paths = ['/Users/gatilin/PycharmProjects/model-metrics-plot/data/loss/0821/pretrain.log', 148 | # '/Users/gatilin/PycharmProjects/model-metrics-plot/data/loss/0821/finetuning.log'] 149 | # file_paths = ['/Users/gatilin/PycharmProjects/model-metrics-plot/data/loss/0818/pretrain.log', 150 | # '/Users/gatilin/PycharmProjects/model-metrics-plot/data/loss/0818/finetuning.log'] 151 | file_paths = ['/Users/gatilin/PycharmProjects/model-metrics-plot/data/pretrain.txt', 152 | '/Users/gatilin/PycharmProjects/model-metrics-plot/data/finetuning.log'] 153 | plot_mult_loss_curve(file_paths) -------------------------------------------------------------------------------- /plots/model_per_plt.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | 3 | def extract_data_from_txt(file_path): 4 | with open(file_path, 'r') as f: 5 | lines = f.readlines() 6 | 7 | start_flag = '===========================【operators】===========================' 8 | end_flag = '===========================【inputs】==============================' 9 | 10 | start_index = None 11 | end_index = None 12 | 13 | for i, line in enumerate(lines): 14 | if line.startswith(start_flag): 15 | start_index = i + 1 16 | elif line.startswith(end_flag): 17 | end_index = i - 1 18 | break 19 | 20 | if start_index is None or end_index is None: 21 | raise ValueError('Operators section not found in the file.') 22 | 23 | operators_data = [] 24 | for line in lines[start_index:end_index + 1]: 25 | if line.startswith('|'): 26 | operator, count_percentage = line.split(':') 27 | operator = operator.strip('| ') 28 | count, percentage = count_percentage.split(', ') 29 | percentage = float(percentage.strip('percentage=')) 30 | operators_data.append((operator, percentage)) 31 | 32 | return operators_data 33 | 34 | 35 | def plot_pie_chart(operators_data, file_name, top_n=10): 36 | print(operators_data) 37 | labels = [operator for operator, _ in operators_data] 38 | sizes = [percentage for _, percentage in operators_data] 39 | 40 | if len(labels) > top_n: 41 | labels = labels[:top_n] 42 | sizes = sizes[:top_n] 43 | labels.append('others') 44 | sizes.append(100 - sum(sizes)) 45 | # Set the size of the figure using figsize parameter 46 | fig, ax = plt.subplots(figsize=(12, 8)) 47 | wedges, texts, autotexts = ax.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=90) 48 | ax.axis('equal') 49 | 50 | # Add legend with fontsize parameter to set the font size 51 | plt.title(f"Operators Percentage for {file_name}", y=1.05) 52 | plt.legend(wedges, labels, loc="lower right", bbox_to_anchor=(1, 0), fontsize=10) 53 | plt.savefig(f'{file_name}_operators_percentage_pie_chart.png') # save the figure to file 54 | plt.show() 55 | 56 | if __name__ == "__main__": 57 | # file_path = "/Users/gatilin/PycharmProjects/house-of-model-cards1/model_cards/timm/vgg/vgg11/vgg11.txt" 58 | # file_path = "/Users/gatilin/PycharmProjects/onnx-easy-tools/alexnet/alexnet.txt" 59 | # file_path = '/Users/gatilin/PycharmProjects/onnx-easy-tools/infos/mmyolo/yolov5_l-p6-v62_syncbn_fast_8xb16-300e_coco/yolov5_l-p6-v62_syncbn_fast_8xb16-300e_coco.txt' 60 | # file_path = '/Users/gatilin/PycharmProjects/onnx-easy-tools/infos/mmyolo/yolov5_l-p6-v62_syncbn_fast_8xb16-300e_coco/yolov5_l-p6-v62_syncbn_fast_8xb16-300e_coco.txt' 61 | # file_path = '/Users/gatilin/PycharmProjects/onnx-easy-tools/infos/detectron2/Cityscapes/mask_rcnn_R_50_FPN/mask_rcnn_R_50_FPN.txt' 62 | # file_path = '/Users/gatilin/PycharmProjects/onnx-easy-tools/infos/detectron2/COCO-Detection/rpn_R_50_C4_1x/rpn_R_50_C4_1x.txt' 63 | file_path = '/Users/gatilin/PycharmProjects/onnx-easy-tools/vgg16/vgg16.txt' 64 | file_name = file_path.split('/')[-1].split('.')[0] 65 | operators_data = extract_data_from_txt(file_path) 66 | plot_pie_chart(operators_data, file_name) -------------------------------------------------------------------------------- /plots/mult_chart_plot.py: -------------------------------------------------------------------------------- 1 | 2 | import matplotlib.pyplot as plt 3 | import pandas as pd 4 | import numpy as np 5 | 6 | from utils.dataloader import pd_read_csv 7 | 8 | def plot_chart(df,fig_path,is_grid,title_name,font_size): 9 | # 提取数据 10 | categories = list(df.columns[1:]) 11 | values = df.values[:, 1:] 12 | model_labels = df.values[:, 0] 13 | 14 | # 计算角度 15 | angles = np.linspace(0, 2 * np.pi, len(categories), endpoint=False).tolist() 16 | angles += angles[:1] # 闭合多边形 17 | 18 | fig, ax = plt.subplots(figsize=(16, 16), subplot_kw=dict(polar=True)) 19 | 20 | # 设置坐标标签字体大小 21 | plt.xticks(fontsize=font_size) 22 | plt.yticks(fontsize=font_size) 23 | 24 | if is_grid is False: 25 | # 隐藏最外圈的圆 26 | ax.spines['polar'].set_visible(False) 27 | # 隐藏圆形网格线 28 | ax.grid(False) 29 | 30 | # 绘制每一行数据的多边形 31 | for i, row in enumerate(values): 32 | data = np.concatenate((row, [row[0]])) # 闭合多边形 33 | label_name = model_labels[i] 34 | 35 | ax.plot(angles, data, label=label_name) # 绘制多边形 36 | # ax.legend(label_name, fontsize=18) 37 | ax.fill(angles, data, alpha=0.25) # 填充多边形 38 | # 添加图例并设置位置 39 | # ax.legend(bbox_to_anchor=(1, 0), loc='lower right') 40 | 41 | # 设置刻度、标签和标题 42 | ax.set_xticks(angles[:-1]) 43 | # plt.legend(loc="lower left") 44 | 45 | ax.set_xticklabels(categories) 46 | ax.set_title(title_name, fontsize=font_size) 47 | 48 | # 添加图例 49 | ax.legend(bbox_to_anchor=(1.0, 1.1)) 50 | 51 | # 显示图形 52 | plt.show() 53 | 54 | # 保存图形 55 | fig.savefig(fig_path, dpi=300, bbox_inches='tight', transparent=True) 56 | 57 | if __name__ == '__main__': 58 | csv_path = '../data/llm_code_eval.csv' 59 | fig_path = '../img/plot_mult_code_chart.jpg' 60 | is_grid = False 61 | title_name = 'LLM Eval' 62 | plot_type = 'chart' 63 | font_size = 18 64 | df = pd_read_csv(csv_path) 65 | plot_chart(df, fig_path, is_grid, title_name, font_size) 66 | -------------------------------------------------------------------------------- /plots/pie_metric_plot.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import pandas as pd 3 | 4 | def pie_chart(data_file, label_col, value_col): 5 | """ 6 | 绘制饼图 7 | 8 | Args: 9 | data_file: str, csv 文件路径 10 | label_col: str, 标签列名 11 | value_col: str, 值列名 12 | """ 13 | # 读取 csv 文件 14 | df = pd.read_csv(data_file) 15 | 16 | # 获取数据 17 | labels = df[label_col] 18 | values = df[value_col] 19 | 20 | # 绘制饼图 21 | plt.pie(values, labels=labels, autopct='%1.1f%%') 22 | 23 | # 设置图表标题 24 | plt.title('{} vs {}'.format(label_col, value_col)) 25 | 26 | # 显示图表 27 | plt.show() 28 | 29 | plt.savefig('../output/{}_vs_{}.png'.format(label_col, value_col)) 30 | 31 | 32 | 33 | if __name__ == '__main__': 34 | # 示例:绘制 'Metric' 列和 'Java' 列的饼图 35 | pie_chart('/Users/gatilin/PycharmProjects/model-metrics-plot/data/llm_code_eval.csv', 'Metric', 'Java') -------------------------------------------------------------------------------- /plots/point_metric_plot.py: -------------------------------------------------------------------------------- 1 | 2 | import matplotlib.pyplot as plt 3 | import pandas as pd 4 | 5 | def scatter_plot(data_file, x_col, y_col): 6 | """ 7 | 绘制散点图 8 | 9 | Args: 10 | data_file: str, csv 文件路径 11 | x_col: str, 横坐标列名 12 | y_col: str, 纵坐标列名 13 | """ 14 | # 读取 csv 文件 15 | df = pd.read_csv(data_file) 16 | 17 | # 获取数据 18 | x = df[x_col] 19 | y = df[y_col] 20 | 21 | # 绘制散点图 22 | plt.scatter(x, y) 23 | 24 | # 设置图表标题和横纵坐标标签 25 | plt.title('{} vs {}'.format(x_col, y_col)) 26 | plt.xlabel(x_col) 27 | plt.ylabel(y_col) 28 | plt.savefig('../output/{}_vs_{}.png'.format(x_col, y_col)) 29 | # 显示图表 30 | plt.show() 31 | 32 | def scatter_all_plot(data_file): 33 | """ 34 | 绘制散点图 35 | 36 | Args: 37 | data_file: str, csv 文件路径 38 | """ 39 | # 读取 csv 文件 40 | df = pd.read_csv(data_file) 41 | 42 | # 获取列名 43 | cols = df.columns.tolist() 44 | 45 | # 绘制散点图 46 | for i in range(1, len(cols)): 47 | for j in range(i): 48 | x_col = cols[i] 49 | y_col = cols[j] 50 | x = df[x_col] 51 | y = df[y_col] 52 | plt.scatter(x, y) 53 | plt.xlabel(x_col) 54 | plt.ylabel(y_col) 55 | plt.title('{} vs {}'.format(x_col, y_col)) 56 | plt.savefig('../output/{}_vs_{}.png'.format(x_col, y_col)) 57 | plt.show() 58 | 59 | 60 | 61 | if __name__ == '__main__': 62 | # 示例:绘制 'Average' vs 'Java' 的散点图 63 | scatter_plot('../data/llm_code_eval.csv', 'Average', 'Java') 64 | 65 | # 示例:绘制所有列的散点图 66 | scatter_all_plot('../data/llm_code_eval.csv') -------------------------------------------------------------------------------- /plots/point_plot.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import seaborn as sns 3 | import matplotlib.pyplot as plt 4 | 5 | class Plotting: 6 | def __init__(self, data_file_path): 7 | self.data_file_path = data_file_path 8 | self.data = pd.read_csv(data_file_path) 9 | 10 | def scatter_plot(self): 11 | sns.set(style="whitegrid") 12 | plt.figure(figsize=(8, 6)) 13 | 14 | sns.scatterplot(data=self.data, x="x", y="y", marker="o", color="b", label="Data Points") 15 | 16 | plt.title("Scatter Plot using Seaborn") 17 | plt.xlabel("X-axis") 18 | plt.ylabel("Y-axis") 19 | plt.legend() 20 | plt.show() 21 | 22 | def linear_regression_plot(self): 23 | sns.set(style="whitegrid") 24 | plt.figure(figsize=(8, 6)) 25 | 26 | sns.regplot(data=self.data, x="x", y="y", scatter_kws={"color": "blue"}, line_kws={"color": "red"}) 27 | 28 | plt.title("Linear Regression Plot using Seaborn") 29 | plt.xlabel("X-axis") 30 | plt.ylabel("Y-axis") 31 | plt.show() 32 | 33 | def histogram_plot(self): 34 | sns.set(style="whitegrid") 35 | plt.figure(figsize=(8, 6)) 36 | 37 | sns.histplot(data=self.data, x="x", bins=10, color="green", kde=True) 38 | 39 | plt.title("Histogram using Seaborn") 40 | plt.xlabel("X-axis") 41 | plt.ylabel("Frequency") 42 | plt.show() 43 | 44 | if __name__ == '__main__': 45 | plotting = Plotting("../data/data.csv") 46 | plotting.scatter_plot() 47 | plotting.linear_regression_plot() 48 | plotting.histogram_plot() -------------------------------------------------------------------------------- /plots/pplot.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import numpy as np 3 | import matplotlib.pyplot as plt 4 | import seaborn as sns 5 | from mpl_toolkits.mplot3d import Axes3D 6 | from sklearn.tree import DecisionTreeClassifier, plot_tree 7 | 8 | def plot_bubble_chart(df, x_col, y_col, value_col): 9 | """ 10 | 绘制气泡图 11 | 12 | 参数: 13 | df:DataFrame,数据集 14 | x_col:str,x 轴所用的列名 15 | y_col:str,y 轴所用的列名 16 | value_col:str,气泡大小所用的列名 17 | 18 | 返回值: 19 | 无 20 | """ 21 | plt.scatter(df[x_col], df[y_col], s=df[value_col]) 22 | plt.title('Bubble Chart') 23 | plt.show() 24 | 25 | # 示例数据 26 | df = pd.DataFrame({ 27 | 'x': [1, 2, 3, 4, 5, 6], 28 | 'y': [4, 5, 6, 7, 8, 9], 29 | 'value': [10, 20, 30, 15, 25, 35] 30 | }) 31 | plot_bubble_chart(df, 'x', 'y', 'value') 32 | 33 | def plot_matrix_chart(df): 34 | """ 35 | 绘制矩阵图 36 | 37 | 参数: 38 | df:DataFrame,数据集 39 | 40 | 返回值: 41 | 无 42 | """ 43 | corr_matrix = df.corr() 44 | sns.heatmap(corr_matrix, annot=True, cmap='YlGnBu') 45 | plt.title('Matrix Chart') 46 | plt.show() 47 | 48 | # 示例数据 49 | df = pd.DataFrame({ 50 | 'x': [1, 2, 3, 4, 5, 6], 51 | 'y': [4, 5, 6, 7, 8, 9], 52 | 'value': [10, 20, 30, 15, 25, 35] 53 | }) 54 | plot_matrix_chart(df) 55 | 56 | def plot_3d_scatter_chart(df, x_col, y_col, value_col): 57 | """ 58 | 绘制三维散点图 59 | 60 | 参数: 61 | df:DataFrame,数据集 62 | x_col:str,x 轴所用的列名 63 | y_col:str,y 轴所用的列名 64 | value_col:str,z 轴所用的列名 65 | 66 | 返回值: 67 | 无 68 | """ 69 | fig = plt.figure() 70 | ax = fig.add_subplot(111, projection='3d') 71 | ax.scatter(df[x_col], df[y_col], df[value_col]) 72 | ax.set_xlabel('X Label') 73 | ax.set_ylabel('Y Label') 74 | ax.set_zlabel('Value Label') 75 | plt.title('3D Scatter Chart') 76 | plt.show() 77 | 78 | # 示例数据 79 | df = pd.DataFrame({ 80 | 'x': [1, 2, 3, 4, 5, 6], 81 | 'y': [4, 5, 6, 7, 8, 9], 82 | 'value': [10, 20, 30, 15, 25, 35] 83 | }) 84 | plot_3d_scatter_chart(df, 'x', 'y', 'value') 85 | 86 | # def plot_spider_chart(df, category_col, value_col): 87 | # """ 88 | # 绘制蜘蛛图 89 | # 90 | # 参数: 91 | # df:DataFrame,数据集 92 | # category_col:str,分类所用的列名 93 | # value_col:str,值所用的列名 94 | # 95 | # 返回值: 96 | # 无 97 | # """ 98 | # categories = df[category_col].unique() 99 | # values = df.groupby(category_col)[value_col].sum().values 100 | # angles = np.linspace(0, 2*np.pi, len(categories), endpoint=False) 101 | # values = np.concatenate((values,[values[0]])) 102 | # angles = np.concatenate((angles,[angles[0]])) 103 | # fig = plt.figure() 104 | # ax = fig.add_subplot(111, polar=True) 105 | # ax.plot(angles, values, 'o-', linewidth=2) 106 | # ax.fill(angles, values, alpha=0.25) 107 | # ax.set_thetagrids(angles * 180/np.pi, categories) 108 | # plt.title('Spider Chart') 109 | # plt.show() 110 | # 111 | # # 示例数据 112 | # # df = pd.DataFrame({ 113 | # # 'category': ['A', 'A', 'A', 'B', 'B', 'B'], 114 | # # 'value': [10, 20, 30, 15, 25, 35] 115 | # # }) 116 | # 117 | # # 蜘蛛图示例数据 118 | # df = pd.DataFrame({ 119 | # 'category': ['A', 'A', 'A', 'B', 'B', 'B'], 120 | # 'value': [10, 20, 30, 15, 25, 35] 121 | # }) 122 | # 123 | # plot_spider_chart(df, 'category', 'value') 124 | 125 | import numpy as np 126 | import pandas as pd 127 | import matplotlib.pyplot as plt 128 | 129 | def plot_spider_chart(df, category_col, value_col): 130 | """ 131 | 绘制蜘蛛图 132 | 133 | 参数: 134 | df:DataFrame,数据集 135 | category_col:str,分类所用的列名 136 | value_col:str,值所用的列名 137 | 138 | 返回值: 139 | 无 140 | """ 141 | categories = df[category_col].unique() 142 | values = df.groupby(category_col)[value_col].sum().values 143 | angles = np.linspace(0, 2*np.pi, len(categories), endpoint=False) 144 | values = np.concatenate((values,[values[0]])) 145 | angles = np.concatenate((angles,[angles[0]])) 146 | fig = plt.figure() 147 | ax = fig.add_subplot(111, polar=True) 148 | ax.plot(angles, values, 'o-', linewidth=2) 149 | ax.fill(angles, values, alpha=0.25) 150 | # 设置刻度、标签和标题 151 | ax.set_xticks(angles[:-1]) 152 | ax.set_xticklabels(categories) 153 | ax.set_title('Spider Chart') 154 | plt.show() 155 | 156 | # 示例数据 157 | df = pd.DataFrame({ 158 | 'category': ['A', 'A', 'A', 'B', 'B', 'B'], 159 | 'value': [10, 20, 30, 15, 25, 35] 160 | }) 161 | plot_spider_chart(df, 'category', 'value') 162 | 163 | def plot_rose_chart(df, category_col, value_col): 164 | """ 165 | 绘制玫瑰图 166 | 167 | 参数: 168 | df:DataFrame,数据集 169 | category_col:str,分类所用的列名 170 | value_col:str,值所用的列名 171 | 172 | 返回值: 173 | 无 174 | """ 175 | theta = np.linspace(0, 2*np.pi, len(df[category_col]), endpoint=False) 176 | radii = df[value_col].values 177 | width = np.pi/4 178 | fig = plt.figure() 179 | ax = fig.add_subplot(111, projection='polar') 180 | bars = ax.bar(theta, radii, width=width, bottom=0.0) 181 | for r, bar in zip(radii, bars): 182 | bar.set_alpha(0.5) 183 | bar.set_facecolor(plt.cm.jet(r/10.)) 184 | plt.title('Rose Chart') 185 | plt.show() 186 | 187 | # 示例数据 188 | df = pd.DataFrame({ 189 | 'category': ['A', 'B', 'C', 'D'], 190 | 'value': [10, 20, 30, 40] 191 | }) 192 | plot_rose_chart(df, 'category', 'value') 193 | 194 | def plot_radar_chart(df, category_col, value_col): 195 | """ 196 | 绘制雷达图 197 | 198 | 参数: 199 | df:DataFrame,数据集 200 | category_col:str,分类所用的列名 201 | value_col:str,值所用的列名 202 | 203 | 返回值: 204 | 无 205 | """ 206 | categories = df[category_col].unique() 207 | values = df.groupby(category_col)[value_col].sum().values 208 | angles = np.linspace(0, 2*np.pi, len(categories), endpoint=False) 209 | values = np.concatenate((values,[values[0]])) 210 | angles = np.concatenate((angles,[angles[0]])) 211 | fig = plt.figure() 212 | ax = fig.add_subplot(111, polar=True) 213 | ax.plot(angles, values, 'o-', linewidth=2) 214 | ax.fill(angles, values, alpha=0.25) 215 | # ax.set_thetagrids(angles * 180/np.pi, categories) 216 | # 设置刻度、标签和标题 217 | ax.set_xticks(angles[:-1]) 218 | ax.set_xticklabels(categories) 219 | plt.title('Radar Chart') 220 | plt.show() 221 | 222 | # 示例数据 223 | df = pd.DataFrame({ 224 | 'category': ['A', 'A', 'B', 'B'], 225 | 'value': [10, 20, 30, 40] 226 | }) 227 | plot_radar_chart(df, 'category', 'value') -------------------------------------------------------------------------------- /plots/seaborn_plots.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import numpy as np 3 | import matplotlib.pyplot as plt 4 | import seaborn as sns 5 | from mpl_toolkits.mplot3d import Axes3D 6 | from sklearn.datasets import make_blobs 7 | from sklearn.tree import DecisionTreeClassifier, plot_tree 8 | 9 | class DataVisualization: 10 | def __init__(self, data_file): 11 | self.df = pd.read_csv(data_file) 12 | 13 | def bubble_chart(self): 14 | plt.scatter(self.df['x'], self.df['y'], s=self.df['value']) 15 | plt.title('Bubble Chart') 16 | plt.show() 17 | 18 | def matrix_chart(self): 19 | corr_matrix = self.df.corr() 20 | sns.heatmap(corr_matrix, annot=True, cmap='YlGnBu') 21 | plt.title('Matrix Chart') 22 | plt.show() 23 | 24 | def scatter_3d_chart(self): 25 | fig = plt.figure() 26 | ax = fig.add_subplot(111, projection='3d') 27 | ax.scatter(self.df['x'], self.df['y'], self.df['value']) 28 | ax.set_xlabel('X Label') 29 | ax.set_ylabel('Y Label') 30 | ax.set_zlabel('Value Label') 31 | plt.title('3D Scatter Chart') 32 | plt.show() 33 | 34 | def spider_chart(self): 35 | categories = self.df['category'].unique() 36 | values = self.df.groupby('category')['value'].sum().values 37 | angles = np.linspace(0, 2*np.pi, len(categories), endpoint=False) 38 | values = np.concatenate((values,[values[0]])) 39 | angles = np.concatenate((angles,[angles[0]])) 40 | fig = plt.figure() 41 | ax = fig.add_subplot(111, polar=True) 42 | ax.plot(angles, values, 'o-', linewidth=2) 43 | ax.fill(angles, values, alpha=0.25) 44 | ax.set_thetagrids(angles * 180/np.pi, categories) 45 | plt.title('Spider Chart') 46 | plt.show() 47 | 48 | def rose_chart(self): 49 | theta = np.linspace(0, 2*np.pi, len(self.df['category']), endpoint=False) 50 | radii = self.df['value'].values 51 | width = np.pi/4 52 | fig = plt.figure() 53 | ax = fig.add_subplot(111, projection='polar') 54 | bars = ax.bar(theta, radii, width=width, bottom=0.0) 55 | for r, bar in zip(radii, bars): 56 | bar.set_alpha(0.5) 57 | bar.set_facecolor(plt.cm.jet(r/10.)) 58 | plt.title('Rose Chart') 59 | plt.show() 60 | 61 | def radar_chart(self): 62 | categories = self.df['category'].unique() 63 | values = self.df.groupby('category')['value'].sum().values 64 | angles = np.linspace(0, 2*np.pi, len(categories), endpoint=False) 65 | values = np.concatenate((values,[values[0]])) 66 | angles = np.concatenate((angles,[angles[0]])) 67 | fig = plt.figure() 68 | ax = fig.add_subplot(111, polar=True) 69 | ax.plot(angles, values, 'o-', linewidth=2) 70 | ax.fill(angles, values, alpha=0.25) 71 | ax.set_thetagrids(angles * 180/np.pi, categories) 72 | plt.title('Radar Chart') 73 | plt.show() 74 | 75 | def forest_chart(self): 76 | X, y = make_blobs(n_samples=100, centers=2, n_features=2, random_state=0) 77 | clf = DecisionTreeClassifier(random_state=0) 78 | clf.fit(X, y) 79 | plt.figure() 80 | plot_tree(clf, filled=True) 81 | plt.title('Forest Chart') 82 | plt.show() 83 | 84 | def histogram(self, column, bins=10): 85 | plt.hist(self.df[column], bins=bins) 86 | plt.title('Histogram') 87 | plt.xlabel(column) 88 | plt.ylabel('Frequency') 89 | plt.show() 90 | 91 | def box_plot(self, column): 92 | sns.boxplot(x=self.df[column]) 93 | plt.title('Box Plot') 94 | plt.xlabel(column) 95 | plt.show() 96 | 97 | def violin_plot(self, column, category): 98 | sns.violinplot(x=category, y=column, data=self.df) 99 | plt.title('Violin Plot') 100 | plt.xlabel(category) 101 | plt.ylabel(column) 102 | plt.show() 103 | 104 | def bar_chart(self, category, value): 105 | sns.barplot(x=category, y=value, data=self.df) 106 | plt.title('Bar Chart') 107 | plt.xlabel(category) 108 | plt.ylabel(value) 109 | plt.show() 110 | 111 | def pie_chart(self, column): 112 | values = self.df[column].value_counts().values 113 | labels = self.df[column].value_counts().index 114 | plt.pie(values, labels=labels, autopct='%1.1f%%') 115 | plt.title('Pie Chart') 116 | plt.show() 117 | 118 | def dual_axis_chart(self, column1, column2): 119 | fig, ax1 = plt.subplots() 120 | ax1.plot(self.df[column1], 'b-') 121 | ax1.set_xlabel('Index') 122 | ax1.set_ylabel(column1, color='b') 123 | ax1.tick_params('y', colors='b') 124 | 125 | ax2 = ax1.twinx() 126 | ax2.plot(self.df[column2], 'r-') 127 | ax2.set_ylabel(column2, color='r') 128 | ax2.tick_params('y', colors='r') 129 | 130 | plt.title('Dual Axis Chart') 131 | plt.show() 132 | 133 | 134 | if __name__ == '__main__': 135 | data_visualization = DataVisualization('../data/data2.csv') 136 | data_visualization.bubble_chart() 137 | data_visualization.matrix_chart() 138 | data_visualization.scatter_3d_chart() 139 | # data_visualization.spider_chart() 140 | data_visualization.rose_chart() 141 | # data_visualization.radar_chart() 142 | data_visualization.forest_chart() -------------------------------------------------------------------------------- /plots/xlsx_tb_sort_plot.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from openpyxl import load_workbook 3 | from openpyxl.utils.dataframe import dataframe_to_rows 4 | import matplotlib.pyplot as plt 5 | 6 | import warnings 7 | warnings.filterwarnings("ignore") 8 | 9 | def save_sorted_data_to_excel(df, numeric_columns, output_file): 10 | ''' 11 | 12 | Args: 13 | df: 14 | numeric_columns: 15 | output_file: 16 | 17 | Returns: 18 | 19 | ''' 20 | with pd.ExcelWriter(output_file, engine='openpyxl') as writer: 21 | for col in numeric_columns: 22 | sorted_df = df.sort_values(by=col, ascending=False) # 按照数值列从高到低排序 23 | writer.book.create_sheet(f'Sorted by {col}') 24 | ws = writer.book[f'Sorted by {col}'] 25 | for r_idx, row in enumerate(dataframe_to_rows(sorted_df, index=False, header=True)): 26 | for c_idx, value in enumerate(row): 27 | cell = ws.cell(row=r_idx + 1, column=c_idx + 1, value=value) 28 | if r_idx > 0 and isinstance(value, str) and value.startswith("http"): 29 | cell.hyperlink = value 30 | writer._save() 31 | 32 | 33 | def plot_bar_graphs(df, numeric_columns, string_columns, show_label=True): 34 | ''' 35 | 36 | Args: 37 | df: 38 | numeric_columns: 39 | string_columns: 40 | 41 | Returns: 42 | 43 | ''' 44 | plt.rcParams['font.size'] = 8 # 设置字体大小 45 | for col in numeric_columns: 46 | for str_col in string_columns: 47 | sorted_df = df.sort_values(by=col, ascending=False) # 按照数值列从高到低排序 48 | plt.figure(figsize=(16, 12)) # 设置图形大小 49 | ax = sorted_df.plot.bar(x=str_col, y=col, legend=False) 50 | # plt.title(f'Bar plot of {str_col} by {col}') 51 | plt.title(f'Bar plot of {str_col} by Perception') 52 | plt.xlabel(str_col) 53 | plt.ylabel(col) 54 | plt.tight_layout() # 自适应调整布局 55 | 56 | # 设置x轴和y轴刻度字体大小 57 | plt.xticks(fontsize=8) 58 | plt.yticks(fontsize=8) 59 | 60 | if show_label: 61 | # 在每个条形上添加数值标注 62 | for i, v in enumerate(sorted_df[col].values): 63 | ax.text(i, v, str(v), ha='center', va='bottom') 64 | 65 | plt.savefig(f'{str_col}_vs_{col}_bar_plot.png', format='png') 66 | 67 | 68 | if __name__ == '__main__': 69 | input_file = "../data/mllm_per_1125.xlsx" # 请替换为你的Excel文件路径 70 | output_file = "output_1125_cog.xlsx" # 输出文件路径 71 | df = pd.read_excel(input_file) 72 | 73 | numeric_columns = df.select_dtypes(include=['number']).columns.tolist() 74 | string_columns = df.select_dtypes(include=['object']).columns.tolist() 75 | 76 | if len(numeric_columns) == 0 or len(string_columns) == 0: 77 | print("请确保数据包含至少一个数值列和一个字符串列。") 78 | else: 79 | save_sorted_data_to_excel(df, numeric_columns, output_file) 80 | plot_bar_graphs(df, numeric_columns, string_columns, show_label=False) 81 | 82 | print("条形图已保存为PNG文件。") 83 | print("排序完成,结果已保存到", output_file) 84 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | omegaconf~=2.3.0 2 | pandas~=1.3.5 3 | matplotlib~=3.4.3 -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | # Inside of setup.cfg 2 | [metadata] 3 | description-file = README.md -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | import subprocess 3 | import time 4 | import setuptools 5 | from setuptools import find_packages, setup 6 | import io 7 | from os import path 8 | 9 | this_directory = path.abspath(path.dirname(__file__)) 10 | with io.open(path.join(this_directory, "README.md"), encoding="utf-8") as f: 11 | long_description = f.read() 12 | 13 | version_file = "mmplot/version.py" 14 | 15 | 16 | def get_version(): 17 | with open(version_file, "r") as f: 18 | exec(compile(f.read(), version_file, "exec")) 19 | return locals()["__version__"] 20 | 21 | 22 | setuptools.setup( 23 | name="mmplot", 24 | version=get_version(), 25 | description="mmp is a plotting library for plotting metrics of deep learning models", 26 | long_description="", 27 | author="isLinXu", 28 | author_email="islinxu@163.com", 29 | keywords="computer vision, object detection,plotting, metrics", 30 | url="https://github.com/isLinXu/model-metrics-plot", 31 | package_dir={'':"mmplot"}, 32 | # packages=find_packages(exclude=("utils", "core")), 33 | classifiers=[ 34 | "Development Status :: 4 - Beta", 35 | "License :: OSI Approved :: Apache Software License", 36 | "Operating System :: OS Independent", 37 | "Programming Language :: Python :: 3", 38 | "Programming Language :: Python :: 3.5", 39 | "Programming Language :: Python :: 3.6", 40 | "Programming Language :: Python :: 3.7", 41 | "Programming Language :: Python :: 3.8", 42 | "Programming Language :: Python :: 3.9", 43 | ], 44 | license="GPL", 45 | zip_safe=False, 46 | ) 47 | -------------------------------------------------------------------------------- /utils/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) isLinXu. All Rights Reserved 3 | from .config import * 4 | from .logger import * 5 | from .dataloader import * 6 | 7 | __all__ = ["config", "dataloader", "logger"] 8 | -------------------------------------------------------------------------------- /utils/colors.py: -------------------------------------------------------------------------------- 1 | import random as random 2 | 3 | 4 | def get_random_color(): 5 | r = random.random() 6 | b = random.random() 7 | g = random.random() 8 | return (r, g, b) 9 | 10 | 11 | colors_common = ['blue', "orange", "green", "red", "purple", 12 | "brown", "pink", "gray", "olive", "cyan", "teal", 13 | "magenta", "lime", "lavender", "black"] 14 | 15 | 16 | colors_hex = [ 17 | '#ed7d31', # 橙色 18 | '#71ad47', # 绿色 19 | '#4474c4', # 蓝色 20 | '#000000', # 黑色 21 | '#fb2404' # 红色 22 | 23 | ] 24 | 25 | 26 | 27 | colors_common_private = [ 28 | # (0.75, 0.85, 0.85), 29 | # 'blue', 30 | (0.678, 0.847, 0.902), 31 | "orange", 32 | "green", 33 | # "red", 34 | # "purple", 35 | "brown", 36 | # "pink", 37 | # "gray", 38 | # "olive", 39 | "cyan", 40 | # "teal", 41 | # "magenta", 42 | # "lime", 43 | # "lavender", 44 | # "black" 45 | # "purple", 46 | # "lime", 47 | # "lavender" 48 | "red" 49 | ] 50 | 51 | colors_light = [ 52 | (0.75, 0.85, 0.85), # 淡蓝色1 53 | (0.95, 0.75, 0.47), # 浅橙色2 54 | (0.71, 0.85, 0.78), # 浅绿色3 55 | (0.91, 0.39, 0.39), # 淡红色4 56 | (0.83, 0.69, 0.92), # 浅紫色5 57 | (0.77, 0.64, 0.48), # 浅棕色6 58 | (0.97, 0.81, 0.87), # 浅粉色7 59 | (0.85, 0.85, 0.85), # 浅灰色8 60 | (0.57, 0.64, 0.48), # 浅橄榄色9 61 | (0.49, 0.86, 0.89), # 浅青色10 62 | (0.36, 0.70, 0.65), # 浅青蓝色11 63 | (0.94, 0.57, 0.92), # 浅洋红色12 64 | (0.67, 0.92, 0.63), # 浅绿黄色13 65 | (0.90, 0.82, 0.92), # 淡薰衣草色14 66 | (0.80, 0.80, 0.80) # 浅灰黑色15 67 | ] 68 | 69 | colors_dark = [ 70 | (0.09, 0.17, 0.36), # 深蓝色1 71 | (0.57, 0.28, 0.00), # 深橙色2 72 | (0.11, 0.36, 0.23), # 深绿色3 73 | (0.61, 0.09, 0.09), # 深红色4 74 | (0.37, 0.18, 0.37), # 深紫色5 75 | (0.30, 0.23, 0.14), # 深棕色6 76 | (0.54, 0.25, 0.35), # 深粉色7 77 | (0.25, 0.25, 0.25), # 深灰色8 78 | (0.21, 0.27, 0.14), # 深橄榄色9 79 | (0.00, 0.29, 0.33), # 深青色10 80 | (0.00, 0.29, 0.35), # 深青蓝色11 81 | (0.35, 0.00, 0.34), # 深洋红色12 82 | (0.19, 0.31, 0.00), # 深绿黄色13 83 | (0.29, 0.21, 0.31), # 深薰衣草色14 84 | (0.20, 0.20, 0.20), # 深灰黑色15 85 | ] 86 | 87 | colors_dark_private = [ 88 | (0.09, 0.17, 0.36), # 深蓝色1 89 | (0.57, 0.28, 0.00), # 深橙色2 90 | (0.11, 0.36, 0.23), # 深绿色3 91 | (0.37, 0.18, 0.37), # 深紫色5 92 | (0.30, 0.23, 0.14), # 深棕色6 93 | (0.25, 0.25, 0.25), # 深灰色8 94 | (0.21, 0.27, 0.14), # 深橄榄色9 95 | (0.00, 0.29, 0.33), # 深青色10 96 | (0.00, 0.29, 0.35), # 深青蓝色11 97 | (0.35, 0.00, 0.34), # 深洋红色12 98 | (0.19, 0.31, 0.00), # 深绿黄色13 99 | (0.29, 0.21, 0.31), # 深薰衣草色14 100 | (0.20, 0.20, 0.20), # 深灰黑色15 101 | ] 102 | 103 | 104 | 105 | colors_classic = [ 106 | (0.12156862745098039, 0.4666666666666667, 0.7058823529411765), # 1. "C0" - 107 | (1.0, 0.4980392156862745, 0.054901960784313725), # 2. "C1" - 108 | (0.17254901960784313, 0.6274509803921569, 0.17254901960784313), # 3. "C2" - 109 | (0.8392156862745098, 0.15294117647058825, 0.1568627450980392), # 4. "C3" - 110 | (0.5803921568627451, 0.403921568627451, 0.7411764705882353), # 5. "C4" - 111 | (0.5490196078431373, 0.33725490196078434, 0.29411764705882354), # 6. "C5" - 112 | (0.8901960784313725, 0.4666666666666667, 0.7607843137254902), # 7. "C6" - 113 | (0.4980392156862745, 0.4980392156862745, 0.4980392156862745), # 8. "C7" - 114 | (0.7372549019607844, 0.7411764705882353, 0.13333333333333333), # 9. "C8" - 115 | (0.09019607843137255, 0.7450980392156863, 0.8117647058823529), # 10. "C9" - 116 | (0.12156862745098039, 0.4666666666666667, 0.7058823529411765), # 11. "C10" - 117 | (0.17254901960784313, 0.6274509803921569, 0.17254901960784313), # 13. "C12" - 118 | (1.0, 0.4980392156862745, 0.054901960784313725), # 12. "C11" - 119 | (0.8392156862745098, 0.15294117647058825, 0.1568627450980392), # 14. "C13" - 120 | (0.5803921568627451, 0.403921568627451, 0.7411764705882353), # 15. "C14" - 121 | ] 122 | -------------------------------------------------------------------------------- /utils/config.py: -------------------------------------------------------------------------------- 1 | 2 | from pathlib import Path 3 | from typing import Dict, Union 4 | 5 | from difflib import get_close_matches 6 | 7 | from omegaconf import DictConfig, OmegaConf 8 | 9 | from utils.logger import LOGGER, colorstr 10 | 11 | # Constants 12 | FILE = Path(__file__).resolve() 13 | ROOT = FILE.parents[1] 14 | DEFAULT_CONFIG = ROOT / "configs/default.yaml" 15 | 16 | 17 | def check_config_mismatch(overrides, cfg): 18 | mismatched = [option for option in overrides if option not in cfg and 'hydra.' not in option] 19 | 20 | for option in mismatched: 21 | LOGGER.info(f"{colorstr(option)} is not a valid key. Similar keys: {get_close_matches(option, cfg, 3, 0.6)}") 22 | if mismatched: 23 | exit() 24 | 25 | def get_config(config: Union[str, DictConfig], overrides: Union[str, Dict] = None): 26 | """ 27 | Load and merge configuration data from a file or dictionary. 28 | 29 | Args: 30 | config (Union[str, DictConfig]): Configuration data in the form of a file name or a DictConfig object. 31 | overrides (Union[str, Dict], optional): Overrides in the form of a file name or a dictionary. Default is None. 32 | 33 | Returns: 34 | OmegaConf.Namespace: Training arguments namespace. 35 | """ 36 | if overrides is None: 37 | overrides = {} 38 | if isinstance(config, (str, Path)): 39 | config = OmegaConf.load(config) 40 | elif isinstance(config, Dict): 41 | config = OmegaConf.create(config) 42 | # override 43 | if isinstance(overrides, str): 44 | overrides = OmegaConf.load(overrides) 45 | elif isinstance(overrides, Dict): 46 | overrides = OmegaConf.create(overrides) 47 | 48 | check_config_mismatch(dict(overrides).keys(), dict(config).keys()) 49 | 50 | return OmegaConf.merge(config, overrides) -------------------------------------------------------------------------------- /utils/dataloader.py: -------------------------------------------------------------------------------- 1 | 2 | import math 3 | import pandas 4 | def pd_read_csv(csv_path): 5 | 6 | df = pandas.read_csv(csv_path) 7 | # print(df) 8 | return df 9 | 10 | def fps_to_ms(fps: int) -> int: 11 | ''' 12 | Convert FPS to a millisecond interval. 13 | Args: 14 | fps: Input FPS as integer. 15 | Returns: 16 | Interval in milliseconds as integer number. 17 | ''' 18 | return math.floor((1 / fps) * 1000) 19 | 20 | if __name__ == '__main__': 21 | csv_path = '/data/model_data.csv' 22 | df = pd_read_csv(csv_path) 23 | print(df.shape) # 返回df的行数和列数 24 | print(df.shape[0]) # 返回df的行数 25 | print(df.shape[1]) # 返回df的列数 26 | 27 | -------------------------------------------------------------------------------- /utils/excel_tools.py: -------------------------------------------------------------------------------- 1 | ''' 2 | pip install openpyxl 3 | ''' 4 | import pandas as pd 5 | 6 | # 读取Excel文件 7 | input_file = "/Users/gatilin/youtu-work/mllm.xlsx" # 请替换为你的Excel文件路径 8 | output_file = "output/output.xlsx" # 输出文件路径 9 | df = pd.read_excel(input_file) 10 | 11 | # 获取所有数值列的列名 12 | numeric_columns = df.select_dtypes(include=['number']).columns.tolist() 13 | str_columns = df.select_dtypes(include=['object']).columns.tolist() 14 | print("数值列:", numeric_columns) 15 | print("字符串列:", str_columns) 16 | 17 | # 根据每个数值列进行排序,并将排序后的数据存储到新的sheet中 18 | with pd.ExcelWriter(output_file) as writer: 19 | for col in numeric_columns: 20 | sorted_df = df.sort_values(by=col) 21 | sorted_df.to_excel(writer, sheet_name=f'Sorted by {col}', index=False) 22 | 23 | print("排序完成,结果已保存到", output_file) -------------------------------------------------------------------------------- /utils/fonts.py: -------------------------------------------------------------------------------- 1 | from matplotlib import rcParams 2 | 3 | # 设置全局字体为Times New Roman 4 | rcParams['font.family'] = 'Times New Roman' 5 | 6 | font_new_roman = {'family': 'Times New Roman', 7 | 'weight': 'bold', 8 | 'size': 18, 9 | } 10 | -------------------------------------------------------------------------------- /utils/logger.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | import os 4 | import logging 5 | 6 | LOGGING_NAME = 'metrics_plots' 7 | def set_logging(name=LOGGING_NAME, verbose=True): 8 | # sets up logging for the given name 9 | rank = int(os.getenv('RANK', -1)) # rank in world for Multi-GPU trainings 10 | level = logging.INFO if verbose and rank in {-1, 0} else logging.ERROR 11 | logging.config.dictConfig({ 12 | "version": 1, 13 | "disable_existing_loggers": False, 14 | "formatters": { 15 | name: { 16 | "format": "%(message)s"}}, 17 | "handlers": { 18 | name: { 19 | "class": "logging.StreamHandler", 20 | "formatter": name, 21 | "level": level,}}, 22 | "loggers": { 23 | name: { 24 | "level": level, 25 | "handlers": [name], 26 | "propagate": False,}}}) 27 | 28 | 29 | 30 | # set_logging(LOGGING_NAME) # run before defining LOGGER 31 | LOGGER = logging.getLogger(LOGGING_NAME) # define globally (used in train.py, val.py, detect.py, etc.) 32 | 33 | def colorstr(*input): 34 | # Colors a string https://en.wikipedia.org/wiki/ANSI_escape_code, i.e. colorstr('blue', 'hello world') 35 | *args, string = input if len(input) > 1 else ("blue", "bold", input[0]) # color arguments, string 36 | colors = { 37 | "black": "\033[30m", # basic colors 38 | "red": "\033[31m", 39 | "green": "\033[32m", 40 | "yellow": "\033[33m", 41 | "blue": "\033[34m", 42 | "magenta": "\033[35m", 43 | "cyan": "\033[36m", 44 | "white": "\033[37m", 45 | "bright_black": "\033[90m", # bright colors 46 | "bright_red": "\033[91m", 47 | "bright_green": "\033[92m", 48 | "bright_yellow": "\033[93m", 49 | "bright_blue": "\033[94m", 50 | "bright_magenta": "\033[95m", 51 | "bright_cyan": "\033[96m", 52 | "bright_white": "\033[97m", 53 | "end": "\033[0m", # misc 54 | "bold": "\033[1m", 55 | "underline": "\033[4m",} 56 | return "".join(colors[x] for x in args) + f"{string}" + colors["end"] 57 | 58 | --------------------------------------------------------------------------------