Home Python常用代码段
Post
Cancel

Python常用代码段

在程序中输出临时文件大小

1
2
3
4
5
6
def print_size_of_model(model):
    torch.save(model.state_dict(), "temp.p")
    print('Size (MB):', os.path.getsize("temp.p")/2**20)
    os.remove('temp.p')

print_size_of_model(model)
This post is licensed under CC BY 4.0 by the author.

模型压缩实战

OpenCV常用代码段-Python