Hugging Face Deployment Checklist
Welcome to the hf_deployment folder! This directory contains everything needed to wrap your ChronoGridFusionNet model into a native Hugging Face model and push it to the Hub.
What is in here?
configuration_chronogrid.py: The Hugging Face config class (stores hyperparameters like image size and num classes).modeling_chronogrid.py: Your PyTorch architecture, wrapped inPreTrainedModel.push_to_hf.py: The script you will run to package everything and push it to your Hugging Face account.
What you need to do BEFORE publishing:
1. Authenticate with Hugging Face
You need to be logged into your Hugging Face account on your terminal so the script can push files.
- Open your terminal and run:
huggingface-cli login - Paste your Hugging Face Access Token (you can generate one with
writepermissions in your account Settings -> Access Tokens).
2. Update the push_to_hf.py script
Open push_to_hf.py and modify two things:
- Line 13: Change
repo_id = "your-username/chronogrid-fusionnet"to your actual HF username and desired repo name. - Line 21: Ensure
model_path = '../models/Chronogrid_fold5.pt'points to the exact.ptfile you saved after training.
3. Provide your Preprocessing logic
Right now, if someone downloads your model, they won't know how to turn a raw grid signal into a 227x227 image.
- Action: Create a
preprocess.pyfile in this folder. It should contain whatever Python code you used (like S-Transform functions) to generate the.jpgheatmaps you used for training. - You will upload this
preprocess.pyfile manually to your Hugging Face repo later, or add anapi.upload_file(...)line inpush_to_hf.pyfor it.
4. Run the Push Script!
When you are ready:
cd /Users/sanathbs/02_College_UG/IEEE-9bus/hf_deployment
pip install transformers huggingface_hub
python push_to_hf.py
5. Finalize the Model Card (README.md)
Once the model is pushed, go to the model's page on huggingface.co and edit the README.md (Model Card).
You should explain:
- What this is: Fault detection for WSCC 9-Bus system.
- How to use it: Provide a small code snippet showing how to use
AutoModel.from_pretrained(...). - Metrics: Paste your final test accuracy and confusion matrix stats.