Views
No views yet
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4# Load model
5tokenizer = AutoTokenizer.from_pretrained("Angad28/spore-sight-fungal-classifier")
6model = AutoModelForSequenceClassification.from_pretrained("Angad28/spore-sight-fungal-classifier")
7
8# Classify DNA sequence
9sequence = "ATGCGTACGTACGTACGTACGTACGTACGTAC"
10inputs = tokenizer(sequence, return_tensors="pt", truncation=True, max_length=512)
11
12with torch.no_grad():
13 outputs = model(**inputs)
14 predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
15 predicted_class = torch.argmax(predictions, dim=-1)
16 confidence = predictions.max()
17
18print(f"Predicted class: {predicted_class.item()}")
19print(f"Confidence: {confidence.item():.3f}")1# GPU setup
2device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
3model = model.to(device)
4
5# Batch processing
6sequences = ["ATGCGTAC...", "CGATCGAT...", "TACGATCG..."]
7inputs = tokenizer(sequences, return_tensors="pt", truncation=True,
8 max_length=512, padding=True).to(device)
9
10with torch.no_grad():
11 outputs = model(**inputs)
12 predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)1# Set environment variables in your .env file
2HF_MODEL_ID='Angad28/spore-sight-fungal-classifier'
3HF_TOKEN='your_hugging_face_token_here'
4
5# Start backend
6npm start1pip install transformers torch
2
3# For GPU support
4pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu1181@misc{spore-sight-fungal-classifier,
2 title={Spore Sight: Fine-tuned Nucleotide Transformer for Fungal Classification},
3 author={Angad28},
4 year={2025},
5 publisher={Hugging Face},
6 url={https://huggingface.co/Angad28/spore-sight-fungal-classifier}
7}