Spaces:
Runtime error
Runtime error
| 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. |