Update README.md
Browse files
README.md
CHANGED
@@ -7,4 +7,36 @@ license: gpl-3.0
|
|
7 |
|
8 |
This model has been pushed to the Hub using the [PytorchModelHubMixin](https://huggingface.co/docs/huggingface_hub/package_reference/mixins#huggingface_hub.PyTorchModelHubMixin) integration:
|
9 |
- Library: [More Information Needed]
|
10 |
-
- Docs: [More Information Needed]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
This model has been pushed to the Hub using the [PytorchModelHubMixin](https://huggingface.co/docs/huggingface_hub/package_reference/mixins#huggingface_hub.PyTorchModelHubMixin) integration:
|
9 |
- Library: [More Information Needed]
|
10 |
+
- Docs: [More Information Needed]
|
11 |
+
|
12 |
+
## Steps to run model
|
13 |
+
- First install [transforna](https://github.com/gitHBDX/TransfoRNA/tree/master)
|
14 |
+
- Example code:
|
15 |
+
```
|
16 |
+
from transforna import GeneEmbeddModel,RnaTokenizer
|
17 |
+
import torch
|
18 |
+
model_name = 'Seq-Struct'
|
19 |
+
model_path = f"HBDX/{model_name}-TransfoRNA"
|
20 |
+
|
21 |
+
#load model and tokenizer
|
22 |
+
model = GeneEmbeddModel.from_pretrained(model_path)
|
23 |
+
model.eval()
|
24 |
+
|
25 |
+
#init tokenizer.
|
26 |
+
tokenizer = RnaTokenizer.from_pretrained(model_path,model_name=model_name)
|
27 |
+
output = tokenizer(['AAAGTCGGAGGTTCGAAGACGATCAGATAC','TTTTCGGAACTGAGGCCATGATTAAGAGGG'])
|
28 |
+
|
29 |
+
#inference
|
30 |
+
#gene_embedds and second input embedds are the latent space representation of the input sequence's odd tokens and even tokens respectively.
|
31 |
+
#In this case, the second input would be the secondary structure of the sequence
|
32 |
+
gene_embedd, second_input_embedd, activations,attn_scores_first,attn_scores_second = \
|
33 |
+
model(output['input_ids'])
|
34 |
+
|
35 |
+
|
36 |
+
#get sub class labels
|
37 |
+
sub_class_labels = model.convert_ids_to_labels(activations)
|
38 |
+
|
39 |
+
#get major class labels
|
40 |
+
major_class_labels = model.convert_subclass_to_majorclass(sub_class_labels)
|
41 |
+
|
42 |
+
```
|