Sanath2709 commited on
Commit
0448c1e
·
verified ·
1 Parent(s): 692d4df

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +62 -38
README.md CHANGED
@@ -1,40 +1,64 @@
1
- # Hugging Face Deployment Checklist
2
-
3
- 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.
4
-
5
- ## What is in here?
6
- 1. `configuration_chronogrid.py`: The Hugging Face config class (stores hyperparameters like image size and num classes).
7
- 2. `modeling_chronogrid.py`: Your PyTorch architecture, wrapped in `PreTrainedModel`.
8
- 3. `push_to_hf.py`: The script you will run to package everything and push it to your Hugging Face account.
9
-
10
- ## What you need to do BEFORE publishing:
11
-
12
- ### 1. Authenticate with Hugging Face
13
- You need to be logged into your Hugging Face account on your terminal so the script can push files.
14
- - Open your terminal and run: `huggingface-cli login`
15
- - Paste your Hugging Face **Access Token** (you can generate one with `write` permissions in your account Settings -> Access Tokens).
16
-
17
- ### 2. Update the `push_to_hf.py` script
18
- Open `push_to_hf.py` and modify two things:
19
- 1. **Line 13:** Change `repo_id = "your-username/chronogrid-fusionnet"` to your actual HF username and desired repo name.
20
- 2. **Line 21:** Ensure `model_path = '../models/Chronogrid_fold5.pt'` points to the exact `.pt` file you saved after training.
21
-
22
- ### 3. Provide your Preprocessing logic
23
- Right now, if someone downloads your model, they won't know how to turn a raw grid signal into a 227x227 image.
24
- - **Action:** Create a `preprocess.py` file in this folder. It should contain whatever Python code you used (like S-Transform functions) to generate the `.jpg` heatmaps you used for training.
25
- - You will upload this `preprocess.py` file manually to your Hugging Face repo later, or add an `api.upload_file(...)` line in `push_to_hf.py` for it.
26
-
27
- ### 4. Run the Push Script!
28
- When you are ready:
29
- ```bash
30
- cd /Users/sanathbs/02_College_UG/IEEE-9bus/hf_deployment
31
- pip install transformers huggingface_hub
32
- python push_to_hf.py
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  ```
34
 
35
- ### 5. Finalize the Model Card (README.md)
36
- Once the model is pushed, go to the model's page on huggingface.co and edit the `README.md` (Model Card).
37
- You should explain:
38
- - **What this is:** Fault detection for WSCC 9-Bus system.
39
- - **How to use it:** Provide a small code snippet showing how to use `AutoModel.from_pretrained(...)`.
40
- - **Metrics:** Paste your final test accuracy and confusion matrix stats.
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: apache-2.0
5
+ tags:
6
+ - pytorch
7
+ - timeseries
8
+ - power-systems
9
+ - fault-detection
10
+ - computer-vision
11
+ - s-transform
12
+ pipeline_tag: image-classification
13
+ ---
14
+
15
+ # ChronoGrid FusionNet: IEEE 9-Bus Fault Detection
16
+
17
+ ## Model Description
18
+ ChronoGrid FusionNet is a highly specialized deep learning architecture designed for the classification of electrical transmission line faults in the IEEE 9-Bus (WSCC) test system. It processes time-series electrical signals that have been transformed into 2D S-Transform heatmaps to detect and classify 11 different fault conditions.
19
+
20
+ The architecture is a fusion of three core components:
21
+ 1. **1D CNN Backbone:** Extracts multi-band temporal distortions from the frequency dimension.
22
+ 2. **BiLSTM Sequence Modeler:** Captures bidirectional evolution of the electrical transient over time.
23
+ 3. **Self-Attention Mechanism:** Dynamically focuses on the most critical time-steps of the fault clearing process.
24
+
25
+ ## Intended Uses
26
+ - **Academic Research:** Benchmarking fault detection algorithms on power systems.
27
+ - **Power System Analysis:** Classifying Single Line to Ground (SLG), Line to Line (LL), Double Line to Ground (LLG), and Three Phase (LLL) faults.
28
+
29
+ ## How to Get Started with the Model
30
+ Because this is a custom PyTorch architecture, you must pass `trust_remote_code=True` when loading the model from Hugging Face.
31
+
32
+ ```python
33
+ import torch
34
+ from transformers import AutoModel, AutoConfig
35
+ from PIL import Image
36
+ import numpy as np
37
+
38
+ # 1. Load the model and configuration
39
+ repo_id = "Sanath2709/chronogrid-fusionnet"
40
+ config = AutoConfig.from_pretrained(repo_id, trust_remote_code=True)
41
+ model = AutoModel.from_pretrained(repo_id, config=config, trust_remote_code=True)
42
+ model.eval()
43
+
44
+ # 2. Preprocess an S-Transform Heatmap Image
45
+ image_path = "path/to/your/s_transform_heatmap.jpg"
46
+ img = Image.open(image_path).convert('L').resize((227, 227))
47
+ arr = np.array(img, dtype=np.float32) / 255.0
48
+ x = torch.tensor(arr).unsqueeze(0)
49
+
50
+ # 3. Run Inference
51
+ with torch.no_grad():
52
+ logits = model(x)[0]
53
+ probs = torch.softmax(logits, dim=1).squeeze().numpy()
54
+
55
+ # 4. Display Results
56
+ FAULT_CLASSES = ['AG','BG','CG','AB','AC','BC','ABG','ACG','BCG','ABCG','NF']
57
+ print("Predictions:", {FAULT_CLASSES[i]: float(probs[i]) for i in range(len(FAULT_CLASSES))})
58
  ```
59
 
60
+ ## Training Data
61
+ The model was trained on synthetic data generated using the **WSCC 9-Bus system** in Simulink, simulating various fault locations, inception angles, and loads. The raw voltage and current signals were converted into 227x227 time-frequency heatmaps using the discrete S-Transform.
62
+
63
+ ## License & Citation
64
+ If you use this model in your research, please refer to the attached manuscript or citation details once published.