mirror of
https://github.com/upscayl/upscayl.git
synced 2024-11-27 17:00:52 +01:00
3.1 KiB
3.1 KiB
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
- This .chn file. 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
- Open chaiNNer and inside its dependency manager (the download button in the top right corner) install PyTorch and NCNN. ONNX is optional.
- Set the correct GPU under the ONNX tab of the settings if you can.
- Load the .chn file you downloaded in the Prerequisites section by clicking File → Open in chaiNNer.
- Select the .pth model you want to convert by clicking the button that says "Click to select a file...".
- Select an output folder under "Base Directory".
- Name that model by typing under "Param/Bin Name".
- Press the Run button (▶️) on top of the window or press F5 on your keyboard.
- Wait for chaiNNer to finish converting. You'll get 2 files: a .bin and a .param
- 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".
- 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.
- Open Upscayl and go to Settings → Add custom models and select your custom models folder.
- Your model should now appear at the bottom of your models list.
- Happy Upscayling 😄