mirror of
https://github.com/upscayl/upscayl.git
synced 2025-02-19 12:15:47 +01:00
36 lines
3.1 KiB
Markdown
36 lines
3.1 KiB
Markdown
This guide explains how you can convert PyTorch models to NCNN models for Upscayl.
|
|
|
|
> [!IMPORTANT]
|
|
> Only PyTorch models are guaranteed to work. You can use a similar process for ONNX models (use onnxsim to simplify the model, install ONNX in dependencies and replace the orange blocks with their cyan equivalents), but it can often fail.
|
|
|
|
## Prerequisites
|
|
- [chaiNNer](https://github.com/chaiNNer-org/chaiNNer)
|
|
- [This .chn file](https://gist.github.com/aaronliu0130/38b996f360dfee86d71130f129920f3a/raw/f06e711e03a4a239e6dc041fadf890a26fdd979a/pth2bin.chn). Right click the link, click "Save link as" and save it wherever you want.
|
|
- A model in PyTorch (.pth) format. This guide is for converting PyTorch to NCNN (Upscayl's format) only.
|
|
- You can get models from https://openmodeldb.info/.
|
|
- A Text Editor
|
|
|
|
## Steps
|
|
|
|
1. Open chaiNNer and inside its dependency manager (the download button in the top right corner) install PyTorch and NCNN. ONNX is optional.
|
|

|
|
2. Set the correct GPU under the ONNX tab of the settings if you can.
|
|

|
|
3. Load the .chn file you downloaded in the Prerequisites section by clicking File → Open in chaiNNer.
|
|
4. Select the .pth model you want to convert by clicking the button that says "Click to select a file...".
|
|
5. Select an output folder under "Base Directory".
|
|
6. Name that model by typing under "Param/Bin Name".
|
|
7. Press the Run button (▶️) on top of the window or press F5 on your keyboard.
|
|

|
|
8. Wait for chaiNNer to finish converting. You'll get 2 files: a .bin and a .param
|
|

|
|
9. Open the .param file and change the first "input" on the second column and all "input"s (usually 2) in the third column to "data".
|
|

|
|
10. Save the .param file and copy the .param and .bin file to your custom models folder named 'models'. If you don't have one, create it.
|
|
11. Open Upscayl and go to Settings → Add custom models and select your custom models folder.
|
|

|
|

|
|
12. Your model should now appear at the bottom of your models list.
|
|

|
|
13. Happy Upscayling 😄
|
|
 |