chaiNNer-org / spandrel

Spandrel gives your project support for various PyTorch architectures meant for AI Super-Resolution, restoration, and inpainting. Based on the model support implemented in chaiNNer.
MIT License
105 stars 7 forks source link

Clamp output tensor to guarantee output range #127

Closed RunDevelopment closed 5 months ago

RunDevelopment commented 5 months ago

Fixes #125.

This clamps the output tensor of the call API to guarantee an output range of 0-1. The documentation already said that the output range is 0-1, so this PR just fixes the issue that some models did not follow this.

As I pointed out in #125, this fix doesn't have a performance impact. For correctness, users of the call API had to clamp the output tensor for correctness anyway. This fix just shifts the burden of who does the clamp to the call API.