Downloads · 30 days
45
1% of all-time downloads
AmelieSchreiber/esm2_t6_8M_UR50D-finetuned-secondary-structure
esm2_t6_8M_UR50D-finetuned-secondary-structure is a token classification model from AmelieSchreiber. Use it when you need labels on individual words, such as names. It is set up for transformers. The card lists the license as mit.
This is a fine-tuned version of esm2t68MUR50D trained on the token classification task to classify amino acids in protein sequences into one of three categories 0: other, 1: alpha helix, 2: beta strand. It was trained…
Downloads · 30 days
45
1% of all-time downloads
All-time downloads
4.9K
Public
Parameters
7.7M
93 MB on disk
Likes
1
Public
Click a slice to open those files.
.bin31 MB · 50%
From the Hugging Face model README
esm2_t6_8M_UR50D) for Token ClassificationThis is a fine-tuned version of esm2_t6_8M_UR50D trained on the token classification task
to classify amino acids in protein sequences into one of three categories 0: other, 1: alpha helix, 2: beta strand. It was trained with
this notebook and achieves
78.13824286786025 % accuracy.
To use, try running:
from transformers import AutoTokenizer, AutoModelForTokenClassification
import numpy as np
# 1. Prepare the Model and Tokenizer
# Replace with the path where your trained model is saved if you're training a new model
model_dir = "AmelieSchreiber/esm2_t6_8M_UR50D-finetuned-secondary-structure"
model = AutoModelForTokenClassification.from_pretrained(model_dir)
tokenizer = AutoTokenizer.from_pretrained(model_dir)
# Define a mapping from label IDs to their string representations
label_map = {0: "Other", 1: "Helix", 2: "Strand"}
# 2. Tokenize the New Protein Sequence
new_protein_sequence = "MAVPETRPNHTIYINNLNEKIKKDELKKSLHAIFSRFGQILDILVSRSLKMRGQAFVIFKEVSSATNALRSMQGFPFYDKPMRIQYAKTDSDIIAKMKGT" # Replace with your protein sequence
tokens = tokenizer.tokenize(new_protein_sequence)
inputs = tokenizer.encode(new_protein_sequence, return_tensors="pt")
# 3. Predict with the Model
with torch.no_grad():
outputs = model(inputs).logits
predictions = np.argmax(outputs[0].numpy(), axis=1)
# 4. Decode the Predictions
predicted_labels = [label_map[label_id] for label_id in predictions]
# Print the tokens along with their predicted labels
for token, label in zip(tokens, predicted_labels):
print(f"{token}: {label}")