Instructions to use kesha-humonen/runic-reader-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use kesha-humonen/runic-reader-2 with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
File size: 769 Bytes
ed46c5d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | """Share of saturated red pixels (painted runes) per image, for domain analysis."""
import json
import sys
import numpy as np
from PIL import Image
def red_share(path):
im = Image.open(path).convert("RGB")
im.draft("RGB", (256, 256))
im.thumbnail((256, 256))
a = np.asarray(im).astype(np.int16)
r, g, b = a[..., 0], a[..., 1], a[..., 2]
return float(((r > 110) & (r - g > 45) & (r - b > 40)).mean())
if __name__ == "__main__":
out = {}
for split in sys.argv[2:]:
for l in open(split):
rec = json.loads(l)
if rec["image"] not in out:
out[rec["image"]] = red_share(f"{sys.argv[1]}/{rec['image']}")
json.dump(out, open(f"{sys.argv[1]}/data/red_share.json", "w"))
print(len(out))
|