one-sixth / ms_ssim_pytorch Goto Github PK
View Code? Open in Web Editor NEWA fast ssim & ms-ssim implement code with pytorch jit.
License: MIT License
A fast ssim & ms-ssim implement code with pytorch jit.
License: MIT License
Hello. I have been looking at the current implementation and I have found that it uses .repeat() on CPU.
However, I would like to propose using .expand() inside the ssim() function. This has several advantages.
First, this will significantly reduce the amount of data passing from CPU to GPU, which is a major bottleneck in CUDA programming. .repeat() copies data. .expand() does not copy data. So there is not much overhead in using .expand() after transferring the kernel to GPU.
Second, this will allow one to remove the 'channel' parameter from SSIM(), which will remove an unnecessary parameter.
Line 115 in 6269c62
why omit the last level?
ms_ssim_val = torch.prod((cs_vals[:-1] ** weights[:-1].unsqueeze(1)) * (ssim_vals[-1] ** weights[-1]), dim=0)
感谢大佬的杰出贡献,速度上确实提升不少。但是在实际运行的时候,我遇到了一些问题。我在我的网络中插入您的SSIMloss,运行代码后,每次都在运行到一半的时候(开始可以运行),内存直接占满爆掉。无论是服务器还是自己的电脑,都是这样。在修改了dataloader的各种参数后,还是出现这种情况。后来我将SSIMloss改为您代码中的loss3,这种情况就没有了。我不太了解您代码的运行情况,但是在实际运行中确实遇到了这个问题,所以向您反馈一下,不知道原因在哪里。
I am now investigating motion artifact correction in MRI images. which metric should I use to evaluate the performance of my model, SSIM or MS-SSIM?
thanks for your great effort to speed up the msssim.
I found nan when backward in very early iter when training. this is because
cs**a => 1/cx**(a-1) when backward
in the early step, the cs is very small, so 1/cs is inf.
I noticed that you use clamp_min(0.) in the msssim.py. I think replace 0 with 0.00001 will fix the nan problem when early train.
ssim_val = ssim_val.clamp_min(0.0001) # avoid 1/x**(a-1) to be inf when x is very close to zero
cs = cs.clamp_min(0.0001)
please correct me if i am wrong
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.