crispr-bert-api / README.md
santu0032's picture
Update README.md
b30051d verified
|
Raw
History Blame Contribute Delete
2.65 kB
---
title: CRISPR-BERT Prediction API
emoji: πŸš€
colorFrom: blue
colorTo: purple
sdk: docker
sdk_version: latest
app_file: app.py
pinned: false
---
# CRISPR-BERT Prediction API
CRISPR off-target prediction API using hybrid CNN-BERT architecture deployed on Hugging Face Spaces.
## πŸš€ API Endpoints
- `GET /` - API information
- `GET /health` - Health check (shows if model is loaded)
- `POST /predict` - Make a single prediction
- `POST /batch_predict` - Make batch predictions
- `GET /model/info` - Get model information
## πŸ“ Usage
### Single Prediction
```bash
curl -X POST https://santu0032-crispr-bert-api.hf.space/predict \
-H "Content-Type: application/json" \
-d '{"sgRNA": "GGTGAGTGAGTGTGTGCGTGTGG", "DNA": "TGTGAGTGTGTGTGTGTGTGTGT"}'
```
### Response
```json
{
"prediction": 0,
"confidence": 0.9919,
"probabilities": {
"class_0": 0.9919,
"class_1": 0.0081
},
"threshold_used": 0.65,
"sgRNA": "GGTGAGTGAGTGTGTGCGTGTGG",
"DNA": "TGTGAGTGTGTGTGTGTGTGTGT",
"timestamp": "2025-10-31T..."
}
```
## πŸ“‹ Model Requirements
- **sgRNA**: Exactly 23 nucleotides (A, T, C, G, or - for indels)
- **DNA**: Exactly 23 nucleotides (A, T, C, G, or - for indels)
## πŸ”§ Files Structure
```
.
β”œβ”€β”€ app.py # Main Flask application
β”œβ”€β”€ requirements.txt # Python dependencies
β”œβ”€β”€ Dockerfile # Docker configuration
β”œβ”€β”€ sequence_encoder.py # Sequence encoding utilities
β”œβ”€β”€ data_loader.py # Data loading utilities
β”œβ”€β”€ final1/
β”‚ └── weight/
β”‚ β”œβ”€β”€ final_model.keras # Trained model
β”‚ β”œβ”€β”€ threshold_schedule.json # Threshold config
β”‚ └── bert_weight/ # BERT weights
└── README.md # This file
```
## 🧬 About CRISPR-BERT
This API uses a hybrid CNN-BERT architecture to predict CRISPR off-target effects:
- **CNN Branch**: Multi-scale convolutions for sequence pattern recognition
- **BERT Branch**: Transformer attention for contextual understanding
- **BiGRU Layers**: Bidirectional GRU for sequence modeling
- **Final Output**: Binary classification (on-target vs off-target)
## πŸ“Š Model Architecture
- **Input**: 23-nt sgRNA and DNA sequences
- **CNN Encoding**: 26x7 one-hot encoding
- **BERT Encoding**: 26 token IDs
- **Output**: Binary prediction with confidence scores
## πŸ”— Integration
Update your backend to use this API:
```bash
MODEL_API_URL=https://santu0032-crispr-bert-api.hf.space
```
## πŸ“ License
MIT License
## πŸ™ Credits
Built with TensorFlow, Flask, and deployed on Hugging Face Spaces.