BeliverK
BeliverK
> 我不确定是否有一种完美的方法来计算 FLOP。一种选择是使用一些软件来估计模型定义中的计数。四处搜索,看起来 facebookresearch 有另一个包含此功能的存储库 ([fvcore](https://github.com/facebookresearch/fvcore/blob/main/docs/flop_count.md)),您可能想尝试一下。 > > 另一种选择是从模型定义中手动估计计数,这说起来容易做起来难!话虽如此,SAM 模型的大部分是基于转换器的,因此,如果您估计[图像编码器](https://github.com/facebookresearch/segment-anything/blob/6fdee8f2727f4506cfbbe553e23b895e27956588/segment_anything/modeling/image_encoder.py#L166C1-L182C17)和[掩码解码器](https://github.com/facebookresearch/segment-anything/blob/6fdee8f2727f4506cfbbe553e23b895e27956588/segment_anything/modeling/transformer.py#L62C1-L106C29)的单个转换器块的 FLOP 计数,则只需乘以模型每个组件中的转换器块数量(图像编码器和掩码器大小配置都可以在[build_sam.py](https://github.com/facebookresearch/segment-anything/blob/main/segment_anything/build_sam.py)脚本中找到),就可以获得总 FLOP 计数的近似值。 Very excellent work! I would like to ask, have you tried to use fvcore to calculate...
from calflops import calculate_flops from torchvision import models import requests from PIL import Image from transformers import SamModel, SamProcessor import torch device = "cuda" if torch.cuda.is_available() else "cpu" model =...
@CYL0089 你好,我也正在学习此领域,想要实现这个问题,可以和您交流一下嘛。我的QQ是1447349969
Hello, I would like to ask if you have successfully calculated the FLIOs of MobileSAM, and it is convenient to communicate