ColorfulSoft / DeOldify.NET

C# implementation of Jason Antic's DeOldify
Apache License 2.0
301 stars 57 forks source link

DeOldify.hmodel using Stable Weights #13

Closed Derek-2423 closed 2 years ago

Derek-2423 commented 3 years ago

Hi - Great package!

Is it please possible to also convert the Stable Weights as well, sometimes they colourize better

Thanks

GlebSBrykin commented 3 years ago

Good afternoon! I tried to do this, but I ran into a problem: it required too much memory to perform coloring with stable weights. Then the work on this was suspended. However, if there is interest in this, I will try to implement it again.

elliotmarks06 commented 2 years ago

I agree that this would be a very useful addition. What does it take to convert the model? I have never heard of the .HMODEL format before...

GlebSBrykin commented 2 years ago

What does it take to convert the model?

To do this, it is needed to read the original .pth checkpoint, extract the parameters of the neural network from it, convert it to the half data type and sequentially save it in binary form to a file.

I have never heard of the .HMODEL format before...

This is not a file format. This is a binary file containing half numbers without any metadata. To read such a file, it is necessary to know in what sequence and what dimension the tensors were written to the file. This is the simplest and most effective way to store weights for a neural network in this case.

ebroglio commented 2 years ago

Is this script available to read the original .pth file and extract the parameters to create the .hmodel file?

GlebSBrykin commented 2 years ago

I tried to do this, but I ran into a problem: it required too much memory to perform coloring with stable weights.

It looks like this problem has been solved. A new convolution algorithm and memory allocation using a different function will solve this problem. Work on stable weights has begun.

GlebSBrykin commented 2 years ago

Stable model support is implemented. See the startup instructions for more information.