ultralytics-thop 2.0.14__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,199 @@
1
+ Metadata-Version: 2.2
2
+ Name: ultralytics-thop
3
+ Version: 2.0.14
4
+ Summary: Ultralytics THOP package for fast computation of PyTorch model FLOPs and parameters.
5
+ Author-email: Ligeng Zhu <ligeng.zhu+github@gmail.com>
6
+ Maintainer-email: Ultralytics <hello@ultralytics.com>
7
+ License: AGPL-3.0
8
+ Project-URL: Homepage, https://ultralytics.com
9
+ Project-URL: Source, https://github.com/ultralytics/thop
10
+ Project-URL: Documentation, https://docs.ultralytics.com
11
+ Project-URL: Bug Reports, https://github.com/ultralytics/thop/issues
12
+ Project-URL: Changelog, https://github.com/ultralytics/thop/releases
13
+ Keywords: FLOPs,PyTorch,Model Analysis
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Education
17
+ Classifier: Intended Audience :: Science/Research
18
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.8
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Topic :: Software Development
27
+ Classifier: Topic :: Scientific/Engineering
28
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
29
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
30
+ Classifier: Operating System :: POSIX :: Linux
31
+ Classifier: Operating System :: MacOS
32
+ Classifier: Operating System :: Microsoft :: Windows
33
+ Requires-Python: >=3.8
34
+ Description-Content-Type: text/markdown
35
+ License-File: LICENSE
36
+ Requires-Dist: numpy
37
+ Requires-Dist: torch
38
+
39
+ <br>
40
+ <a href="https://www.ultralytics.com/" target="_blank"><img src="https://raw.githubusercontent.com/ultralytics/assets/main/logo/Ultralytics_Logotype_Original.svg" width="320" alt="Ultralytics logo"></a>
41
+
42
+ # 🚀 THOP: PyTorch-OpCounter
43
+
44
+ Welcome to the [THOP](https://github.com/ultralytics/thop) repository, your comprehensive solution for profiling PyTorch models by computing the number of Multiply-Accumulate Operations (MACs) and parameters. This tool is essential for deep learning practitioners to evaluate model efficiency and performance.
45
+
46
+ [![GitHub Actions](https://github.com/ultralytics/thop/actions/workflows/format.yml/badge.svg)](https://github.com/ultralytics/thop/actions/workflows/main.yml) <a href="https://discord.com/invite/ultralytics"><img alt="Discord" src="https://img.shields.io/discord/1089800235347353640?logo=discord&logoColor=white&label=Discord&color=blue"></a> <a href="https://community.ultralytics.com/"><img alt="Ultralytics Forums" src="https://img.shields.io/discourse/users?server=https%3A%2F%2Fcommunity.ultralytics.com&logo=discourse&label=Forums&color=blue"></a> <a href="https://reddit.com/r/ultralytics"><img alt="Ultralytics Reddit" src="https://img.shields.io/reddit/subreddit-subscribers/ultralytics?style=flat&logo=reddit&logoColor=white&label=Reddit&color=blue"></a>
47
+
48
+ ## 📄 Description
49
+
50
+ THOP offers an intuitive API to profile PyTorch models by calculating the number of MACs and parameters. This functionality is crucial for assessing the computational efficiency and memory footprint of deep learning models.
51
+
52
+ ## 📦 Installation
53
+
54
+ You can install THOP via pip:
55
+
56
+ [![PyPI - Version](https://img.shields.io/pypi/v/ultralytics-thop?logo=pypi&logoColor=white)](https://pypi.org/project/ultralytics-thop/) [![Downloads](https://static.pepy.tech/badge/ultralytics-thop)](https://www.pepy.tech/projects/ultralytics-thop) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ultralytics-thop?logo=python&logoColor=gold)](https://pypi.org/project/ultralytics-thop/)
57
+
58
+ ```bash
59
+ pip install ultralytics-thop
60
+ ```
61
+
62
+ Alternatively, install the latest version directly from GitHub:
63
+
64
+ ```bash
65
+ pip install --upgrade git+https://github.com/ultralytics/thop.git
66
+ ```
67
+
68
+ ## 🛠 How to Use
69
+
70
+ ### Basic Usage
71
+
72
+ To profile a model, you can use the following example:
73
+
74
+ ```python
75
+ import torch
76
+ from torchvision.models import resnet50
77
+
78
+ from thop import profile
79
+
80
+ model = resnet50()
81
+ input = torch.randn(1, 3, 224, 224)
82
+ macs, params = profile(model, inputs=(input,))
83
+ ```
84
+
85
+ ### Define Custom Rules for Third-Party Modules
86
+
87
+ You can define custom rules for unsupported modules:
88
+
89
+ ```python
90
+ import torch.nn as nn
91
+
92
+
93
+ class YourModule(nn.Module):
94
+ # your definition
95
+ pass
96
+
97
+
98
+ def count_your_model(model, x, y):
99
+ # your rule here
100
+ pass
101
+
102
+
103
+ input = torch.randn(1, 3, 224, 224)
104
+ macs, params = profile(model, inputs=(input,), custom_ops={YourModule: count_your_model})
105
+ ```
106
+
107
+ ### Improve Output Readability
108
+
109
+ Use `thop.clever_format` for a more readable output:
110
+
111
+ ```python
112
+ from thop import clever_format
113
+
114
+ macs, params = clever_format([macs, params], "%.3f")
115
+ ```
116
+
117
+ ## 📊 Results of Recent Models
118
+
119
+ The following table presents the parameters and MACs for popular models. These results can be reproduced using the script `benchmark/evaluate_famous_models.py`.
120
+
121
+ <table align="center">
122
+ <tr>
123
+ <td>
124
+
125
+ | Model | Params(M) | MACs(G) |
126
+ | ---------------- | --------- | ------- |
127
+ | alexnet | 61.10 | 0.77 |
128
+ | vgg11 | 132.86 | 7.74 |
129
+ | vgg11_bn | 132.87 | 7.77 |
130
+ | vgg13 | 133.05 | 11.44 |
131
+ | vgg13_bn | 133.05 | 11.49 |
132
+ | vgg16 | 138.36 | 15.61 |
133
+ | vgg16_bn | 138.37 | 15.66 |
134
+ | vgg19 | 143.67 | 19.77 |
135
+ | vgg19_bn | 143.68 | 19.83 |
136
+ | resnet18 | 11.69 | 1.82 |
137
+ | resnet34 | 21.80 | 3.68 |
138
+ | resnet50 | 25.56 | 4.14 |
139
+ | resnet101 | 44.55 | 7.87 |
140
+ | resnet152 | 60.19 | 11.61 |
141
+ | wide_resnet101_2 | 126.89 | 22.84 |
142
+ | wide_resnet50_2 | 68.88 | 11.46 |
143
+
144
+ </td>
145
+ <td>
146
+
147
+ | Model | Params(M) | MACs(G) |
148
+ | ------------------ | --------- | ------- |
149
+ | resnext50_32x4d | 25.03 | 4.29 |
150
+ | resnext101_32x8d | 88.79 | 16.54 |
151
+ | densenet121 | 7.98 | 2.90 |
152
+ | densenet161 | 28.68 | 7.85 |
153
+ | densenet169 | 14.15 | 3.44 |
154
+ | densenet201 | 20.01 | 4.39 |
155
+ | squeezenet1_0 | 1.25 | 0.82 |
156
+ | squeezenet1_1 | 1.24 | 0.35 |
157
+ | mnasnet0_5 | 2.22 | 0.14 |
158
+ | mnasnet0_75 | 3.17 | 0.24 |
159
+ | mnasnet1_0 | 4.38 | 0.34 |
160
+ | mnasnet1_3 | 6.28 | 0.53 |
161
+ | mobilenet_v2 | 3.50 | 0.33 |
162
+ | shufflenet_v2_x0_5 | 1.37 | 0.05 |
163
+ | shufflenet_v2_x1_0 | 2.28 | 0.15 |
164
+ | shufflenet_v2_x1_5 | 3.50 | 0.31 |
165
+ | shufflenet_v2_x2_0 | 7.39 | 0.60 |
166
+ | inception_v3 | 27.16 | 5.75 |
167
+
168
+ </td>
169
+ </tr>
170
+ </table>
171
+
172
+ ## 💡 Contribute
173
+
174
+ We welcome community contributions to enhance THOP. Please check our [Contributing Guide](https://docs.ultralytics.com/help/contributing/) for more details. Your feedback and suggestions are highly appreciated!
175
+
176
+ ## 📄 License
177
+
178
+ THOP is licensed under the AGPL-3.0 License. For more information, see the [LICENSE](https://github.com/ultralytics/thop/blob/main/LICENSE) file.
179
+
180
+ ## 📮 Contact
181
+
182
+ For bugs or feature requests, please open an issue on [GitHub Issues](https://github.com/ultralytics/thop/pulls). Join our community on [Discord](https://discord.com/invite/ultralytics) for discussions and support.
183
+
184
+ <br>
185
+ <div align="center">
186
+ <a href="https://github.com/ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-github.png" width="3%" alt="Ultralytics GitHub"></a>
187
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
188
+ <a href="https://www.linkedin.com/company/ultralytics/"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-linkedin.png" width="3%" alt="Ultralytics LinkedIn"></a>
189
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
190
+ <a href="https://twitter.com/ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-twitter.png" width="3%" alt="Ultralytics Twitter"></a>
191
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
192
+ <a href="https://youtube.com/ultralytics?sub_confirmation=1"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-youtube.png" width="3%" alt="Ultralytics YouTube"></a>
193
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
194
+ <a href="https://www.tiktok.com/@ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-tiktok.png" width="3%" alt="Ultralytics TikTok"></a>
195
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
196
+ <a href="https://ultralytics.com/bilibili"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-bilibili.png" width="3%" alt="Ultralytics BiliBili"></a>
197
+ <img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
198
+ <a href="https://discord.com/invite/ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-discord.png" width="3%" alt="Ultralytics Discord"></a>
199
+ </div>
@@ -0,0 +1,13 @@
1
+ thop/__init__.py,sha256=OSUVoANnWspwoPV8jMIKVV29T_vwfq0SwK-zB63EwMU,219
2
+ thop/fx_profile.py,sha256=ACI2RLyDYBLB7Cru9y2IAx_YCFX_uhYEArDR0np_tFc,8231
3
+ thop/profile.py,sha256=VaCR0K2oWTHp0y-W3SbuA4TdnyxTP6n6VSURltJGzrE,7980
4
+ thop/rnn_hooks.py,sha256=JKZ2eSCvIKvhvCDqM4oWPZjmBkdyJ4R2Q7XSn63lsX0,6503
5
+ thop/utils.py,sha256=IwFJQ1v-SLyhm-313Li535R6fhtomkm8Fem1Kfe6G_U,1484
6
+ thop/vision/__init__.py,sha256=lm6MckFYCPTbqIoX7w0s_daxdjNeBeKW6DXppv1-QUM,70
7
+ thop/vision/basic_hooks.py,sha256=PlhEIJv4I1NOtcK3pomZxbut8oZ-JhHwJ7NtOLO1rbQ,4708
8
+ thop/vision/calc_func.py,sha256=s-_tRmimNBl4PYY_WQHb3C1H4nLy-oEW2kvsZDVjvdI,4362
9
+ ultralytics_thop-2.0.14.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
10
+ ultralytics_thop-2.0.14.dist-info/METADATA,sha256=Kvy_nKqnpl5s7ABwfVTA1SBbeYhovolYQWy3sOlBXr0,9362
11
+ ultralytics_thop-2.0.14.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
12
+ ultralytics_thop-2.0.14.dist-info/top_level.txt,sha256=HQ7D0gSvDJ31CNR-f0EuXNVve05RYBmwyIkHQKiEhU8,5
13
+ ultralytics_thop-2.0.14.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.8.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ thop