Issue when uploading the models

Issue when uploading the models  

  By: AustinChen on Oct. 25, 2024, 9:49 a.m.

Hi,

I encountered some issues while uploading my models. After compressing the folder containing the model weights and configuration files into a tar.gz format for the upload, my inference code can still not find the folder under /opt/ml/model/. I would like to ask if there are any file type restrictions or if there could be naming issues when decompressing.

Thank you.

Re: Issue when uploading the models  

  By: FazaelAyatollahi on Oct. 25, 2024, 12:40 p.m.

Hi,

There is no special restrictions. My recommendation is to only convert the model weights to ".tar.gz". you can use the following code I used. and keep your other codes and config files in work directory or source folder.

import tarfile
import os

# Path where model saved
model_pth_path = os.path.join(cfg.OUTPUT_DIR, "model_final.pth")

# .tar.gz output path
tar_gz_path = os.path.join(cfg.OUTPUT_DIR, "model_final.tar.gz")

# Compress the .pth file into a tar.gz archive
with tarfile.open(tar_gz_path, "w:gz") as tar:
    tar.add(model_pth_path, arcname=os.path.basename(model_pth_path))

Grand-Chalenge will unzip your model into "/opt/ml/model/model_final.pth" automatically and you can reach it (doesn't need to unzip it)

please let me know if it works