Add library and pipeline tag, include paper and Github info

#1
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +108 -1
README.md CHANGED
@@ -1,4 +1,111 @@
1
  ---
2
  license: apache-2.0
 
 
3
  ---
4
- ### There is the pretrained weights of CBraMod.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ library_name: pytorch
4
+ pipeline_tag: other
5
  ---
6
+
7
+ ### There is the pretrained weights of CBraMod.
8
+
9
+ # CBraMod: A Criss-Cross Brain Foundation Model for EEG Decoding
10
+
11
+ [![Paper](https://img.shields.io/badge/arXiv-2412.07236-red)](https://arxiv.org/abs/2412.07236)
12
+ [![Paper](https://img.shields.io/badge/Paper-ICLR-008B8B)](https://openreview.net/forum?id=NPNUHgHF2w)
13
+ [![huggingface](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Models-FFD21E)](https://huggingface.co/weighting666/CBraMod)
14
+ ![GitHub Repo stars](https://img.shields.io/github/stars/wjq-learning/CBraMod)
15
+
16
+ <div align="center">
17
+ <img src="figure/CBraMod_logo.png" style="width: 15%;" />
18
+ </div>
19
+
20
+ <p align="center">
21
+ πŸ”&nbsp;<a href="#-about">About</a>
22
+ | πŸ”¨&nbsp;<a href="#-setup">Setup</a>
23
+ | 🚒&nbsp;<a href="#-how-to-pretrain">How to Pretrain</a>
24
+ | β›΅&nbsp;<a href="#-how-to-finetune">How to Finetune</a>
25
+ | πŸš€&nbsp;<a href="#-quick-start">Quick Start</a>
26
+ | πŸ”—&nbsp;<a href="#-citation">Citation</a>
27
+ </p>
28
+
29
+ πŸ”₯ NEWS: The paper "_CBraMod: A Criss-Cross Brain Foundation Model for EEG Decoding_" has been accepted by ICLR 2025!
30
+
31
+ ## πŸ” About
32
+ We propose **CBraMod**, a novel EEG foundation model, for EEG decoding on various clinical and BCI application.
33
+ The preprint version of our paper is available at [arXiv](https://arxiv.org/abs/2412.07236).
34
+ The camera-ready version of the paper will be available at [OpenReview](https://openreview.net/forum?id=NPNUHgHF2w).
35
+ <div align="center">
36
+ <img src="figure/model.png" style="width:100%;" />
37
+ </div>
38
+
39
+ ## πŸ”¨ Setup
40
+ Install [Python](https://www.python.org/downloads/).
41
+
42
+ Install [PyTorch](https://pytorch.org/get-started/locally/).
43
+
44
+ Install other requirements:
45
+ ```commandline
46
+ pip install -r requirements.txt
47
+ ```
48
+
49
+ ## 🚒 How to Pretrain
50
+ You can pretrain CBraMod on our pretraining dataset or your custom pretraining dataset using the following code:
51
+ ```commandline
52
+ python pretrain_main.py
53
+ ```
54
+ We have released a pretrained checkpoint on [HugginfaceπŸ€—](https://huggingface.co/weighting666/CBraMod).
55
+
56
+ ## β›΅ How to Finetune
57
+ You can finetune CBraMod on our selected downstream datasets using the following code:
58
+ ```commandline
59
+ python finetune_main.py
60
+ ```
61
+
62
+ ## πŸš€ Quick Start
63
+ You can fine-tune the pretrained CBraMod on your custom downstream dataset using the following example code:
64
+ ```python
65
+ import torch
66
+ import torch.nn as nn
67
+ from models.cbramod import CBraMod
68
+ from einops.layers.torch import Rearrange
69
+
70
+ device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
71
+ model = CBraMod().to(device)
72
+ model.load_state_dict(torch.load('pretrained_weights/pretrained_weights.pth', map_location=device))
73
+ model.proj_out = nn.Identity()
74
+ classifier = nn.Sequential(
75
+ Rearrange('b c s p -> b (c s p)'),
76
+ nn.Linear(22*4*200, 4*200),
77
+ nn.ELU(),
78
+ nn.Dropout(0.1),
79
+ nn.Linear(4 * 200, 200),
80
+ nn.ELU(),
81
+ nn.Dropout(0.1),
82
+ nn.Linear(200, 4),
83
+ ).to(device)
84
+
85
+ # mock_eeg.shape = (batch_size, num_of_channels, time_segments, points_per_patch)
86
+ mock_eeg = torch.randn((8, 22, 4, 200)).to(device)
87
+
88
+ # logits.shape = (batch_size, num_of_classes)
89
+ logits = classifier(model(mock_eeg))
90
+ ```
91
+
92
+ ## πŸ”— Citation
93
+ If you're using this repository in your research or applications, please cite using the following BibTeX:
94
+ ```bibtex
95
+ @inproceedings{wang2025cbramod,
96
+ title={{CB}raMod: A Criss-Cross Brain Foundation Model for {EEG} Decoding},
97
+ author={Jiquan Wang and Sha Zhao and Zhiling Luo and Yangxuan Zhou and Haiteng Jiang and Shijian Li and Tao Li and Gang Pan},
98
+ booktitle={The Thirteenth International Conference on Learning Representations},
99
+ year={2025},
100
+ url={https://openreview.net/forum?id=NPNUHgHF2w}
101
+ }
102
+ ```
103
+
104
+ ## ⭐ Star History
105
+ <div align="center">
106
+ <a href="https://star-history.com/#wjq-learning/CBraMod&Date">
107
+ <img src="https://api.star-history.com/svg?repos=wjq-learning/CBraMod&type=Date" style="width: 80%;" />
108
+ </a>
109
+ </div>
110
+
111
+ Code: https://github.com/wjq-learning/CBraMod