Skip to content

Troubleshooting MissingModels

remsky edited this page Feb 2, 2025 · 1 revision

Missing Models Troubleshooting

If you encounter missing models, you can download them using the provided scripts. The scripts support both Python and Bash, and can download models for either CPU or GPU.

Using the Python Script

  1. Navigate to the Script Directory:

    • Open your terminal or command prompt.
    • Navigate to the directory where the script is located. This is typically Kokoro-FastAPI/docker/scripts.
  2. Run the Script:

    • Use the following command to download the models:
      python download_model.py --type [pth|onnx]
    • Replace [pth|onnx] with pth for PyTorch models or onnx for ONNX models.
    • If you want to overwrite existing files, add the --overwrite flag:
      python download_model.py --type [pth|onnx] --overwrite
  3. Default Models:

    • If you don't provide any URLs, the script will download default models. These are:
      • For PyTorch: kokoro-v0_19.pth and kokoro-v0_19-half.pth
      • For ONNX: kokoro-v0_19.onnx and kokoro-v0_19_fp16.onnx
  4. Custom Models:

    • You can also provide custom URLs to download specific models. To use them, you will need to adjust the environment variable for the targeted model as well. See core/config.py:
      python download_model.py --type [pth|onnx] [URL1] [URL2] ...

Using the Bash Script

  1. Navigate to the Script Directory:

    • Open your terminal or command prompt.
    • Navigate to the directory where the script is located. This is typically Kokoro-FastAPI/docker/scripts.
  2. Run the Script:

    • Use the following command to download the models:
      ./download_model.sh --type [pth|onnx]
    • Replace [pth|onnx] with pth for PyTorch models or onnx for ONNX models.
  3. Default Models:

    • If you don't provide any URLs, the script will download default models. These are:
      • For PyTorch: kokoro-v0_19.pth and kokoro-v0_19-half.pth
      • For ONNX: kokoro-v0_19.onnx and kokoro-v0_19_fp16.onnx
  4. Custom Models:

    • You can also provide custom URLs to download specific models:
      ./download_model.sh --type [pth|onnx] [URL1] [URL2] ...

Explanation of the Scripts

The scripts are designed to download model files from the specified URLs and save them to the api/src/models directory within your project. They handle different model types (PyTorch and ONNX) and can download default models if no URLs are provided.

  • Python Script: This script uses the requests library to download files. It checks if the file already exists and skips the download if it does. It also handles errors gracefully.
  • Bash Script: This script uses curl to download files. It checks if the file already exists and skips the download if it does. It also handles errors gracefully.

Both scripts are located in the Kokoro-FastAPI/docker/scripts directory. You can run them from there or from any directory by providing the full path to the script.