1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-11-24 07:30:19 +01:00
upscayl/docs/Model-Conversion-Guide.md
2024-02-01 18:42:35 -05:00

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.
  • 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. Screenshot_from_2023-08-29_16-40-55
  2. Set the correct GPU under the ONNX tab of the settings if you can. Screenshot from 2023-06-19 00-01-16
  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. Screenshot_from_2023-08-29_16-53-31
  8. Wait for chaiNNer to finish converting. You'll get 2 files: a .bin and a .param Screenshot from 2023-06-18 23-49-50
  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". Screenshot from 2023-06-18 23-50-51
  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. Screenshot from 2023-06-18 23-51-52 Screenshot from 2023-06-18 23-51-58
  12. Your model should now appear at the bottom of your models list. Screenshot from 2023-06-18 23-52-03
  13. Happy Upscayling 😄 Screenshot from 2023-06-18 23-53-45