Update README.md
Browse files
README.md
CHANGED
|
@@ -40,6 +40,7 @@ This model is trained with the following objectives:
|
|
| 40 |
## Quick Start
|
| 41 |
|
| 42 |
```python
|
|
|
|
| 43 |
from transformers import AutoModel, AutoProcessor
|
| 44 |
import torch
|
| 45 |
|
|
@@ -48,12 +49,9 @@ model = AutoModel.from_pretrained("dleemiller/SwipeALot-base", trust_remote_code
|
|
| 48 |
processor = AutoProcessor.from_pretrained("dleemiller/SwipeALot-base", trust_remote_code=True)
|
| 49 |
model.eval()
|
| 50 |
|
| 51 |
-
# Example: Predict word from swipe path
|
| 52 |
-
from datasets import load_dataset
|
| 53 |
-
|
| 54 |
# Load sample
|
| 55 |
-
dataset = load_dataset("futo-org/swipe.futo.org", split="test[:
|
| 56 |
-
item = dataset[
|
| 57 |
|
| 58 |
# Preprocess swipe path using processor methods
|
| 59 |
# 1. Normalize timestamps (x,y already normalized in futo dataset)
|
|
@@ -148,7 +146,7 @@ mask_token_id = processor.tokenizer.mask_token_id
|
|
| 148 |
masked_ids = [mask_token_id if cid != 0 else 0 for cid in char_ids]
|
| 149 |
inputs["input_ids"] = torch.tensor([masked_ids], dtype=torch.long)
|
| 150 |
|
| 151 |
-
# Predict from path only
|
| 152 |
```
|
| 153 |
|
| 154 |
### Length Prediction
|
|
|
|
| 40 |
## Quick Start
|
| 41 |
|
| 42 |
```python
|
| 43 |
+
from datasets import load_dataset
|
| 44 |
from transformers import AutoModel, AutoProcessor
|
| 45 |
import torch
|
| 46 |
|
|
|
|
| 49 |
processor = AutoProcessor.from_pretrained("dleemiller/SwipeALot-base", trust_remote_code=True)
|
| 50 |
model.eval()
|
| 51 |
|
|
|
|
|
|
|
|
|
|
| 52 |
# Load sample
|
| 53 |
+
dataset = load_dataset("futo-org/swipe.futo.org", split="test[:10]")
|
| 54 |
+
item = dataset[4]
|
| 55 |
|
| 56 |
# Preprocess swipe path using processor methods
|
| 57 |
# 1. Normalize timestamps (x,y already normalized in futo dataset)
|
|
|
|
| 146 |
masked_ids = [mask_token_id if cid != 0 else 0 for cid in char_ids]
|
| 147 |
inputs["input_ids"] = torch.tensor([masked_ids], dtype=torch.long)
|
| 148 |
|
| 149 |
+
# Predict from path only
|
| 150 |
```
|
| 151 |
|
| 152 |
### Length Prediction
|