|
--- |
|
library_name: transformers |
|
tags: [] |
|
--- |
|
# Ink detection pipeline using the Grandprize winning model. |
|
### Install the relevant packages using the following command: |
|
```bash |
|
pip install -U vesuvius transformer timesformer-pytorch |
|
vesuvius.accept_terms --yes |
|
``` |
|
## Read ancient text and retrieve 2000 year old letters using this simple code snippet: |
|
```python |
|
import vesuvius |
|
import numpy as np |
|
import matplotlib.pyplot as plt |
|
from vesuvius import Volume |
|
from transformers import pipeline |
|
|
|
|
|
segment = Volume(20230827161847, normalize=True) |
|
|
|
classifier = pipeline(model="scrollprize/ink_detection_pipeline", trust_remote_code=True, tile_size=64, stride=32, scale_factor=16) |
|
prediction = classifier(np.transpose(segment[17:43, 200:5600,1000:4600],(1,2,0)).astype(np.float32)) # prediction shape ~ (512,512) |
|
|
|
plt.imshow(prediction) |
|
``` |