davanstrien HF Staff commited on
Commit
bf19617
·
verified ·
1 Parent(s): c17d549

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +113 -0
README.md ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ viewer: false
3
+ tags:
4
+ - uv-script
5
+ - iiif
6
+ - glam
7
+ - deep-zoom
8
+ - static-tiles
9
+ ---
10
+
11
+ # IIIF Static Tiles from HF Storage Buckets
12
+
13
+ Generate [IIIF Image API 3.0](https://iiif.io/api/image/3.0/) Level 0 static tiles from images and serve them via Hugging Face Storage Buckets — no image server required.
14
+
15
+ Drop images into a bucket, run one command, and get deep-zoom viewing in any IIIF viewer (Mirador, Universal Viewer, OpenSeadragon).
16
+
17
+ ## Demo
18
+
19
+ [View in Mirador](https://projectmirador.org/embed/?iiif-content=https://huggingface.co/buckets/davanstrien/iiif-tiles-streaming/resolve/manifest.json) — 6 pages from the Wellcome Collection, served entirely from an HF Storage Bucket.
20
+
21
+ ## How it works
22
+
23
+ ```
24
+ Source images (bucket or local)
25
+ → tile_iiif.py (pyvips generates tile pyramid)
26
+ → Output bucket (static files served via HF CDN)
27
+ → Any IIIF viewer (deep zoom, pan, browse)
28
+ ```
29
+
30
+ The script generates a complete IIIF Level 0 tile set: a directory tree of pre-rendered JPEG tiles at multiple zoom levels, plus `info.json` descriptors and a IIIF Presentation v3 `manifest.json`. Since everything is static files, any CDN or file server works — no dynamic image server needed.
31
+
32
+ In bucket-to-bucket mode, images are streamed through in small batches (download → tile → upload → cleanup) so local storage stays minimal regardless of collection size.
33
+
34
+ ## Quick start
35
+
36
+ ```bash
37
+ # Bucket to bucket (recommended for large collections)
38
+ uv run tile_iiif.py \
39
+ --source-bucket myorg/source-images \
40
+ --output-bucket myorg/iiif-tiles
41
+
42
+ # From a local directory → HF Bucket
43
+ uv run tile_iiif.py \
44
+ --source-dir ./my-scans \
45
+ --output-bucket myorg/iiif-tiles \
46
+ --collection-name "My Collection"
47
+
48
+ # Local only (for testing)
49
+ uv run tile_iiif.py \
50
+ --source-dir ./my-scans \
51
+ --output-dir ./tiles
52
+ # Then: cd tiles && python -m http.server
53
+ ```
54
+
55
+ No system dependencies — `pyvips[binary]` bundles libvips in the pip wheel.
56
+
57
+ ## Run on HF Jobs
58
+
59
+ Process large collections without tying up your machine:
60
+
61
+ ```bash
62
+ hf jobs uv run tile_iiif.py \
63
+ --source-bucket myorg/source-images \
64
+ --output-bucket myorg/iiif-tiles \
65
+ --collection-name "Historic Manuscripts"
66
+ ```
67
+
68
+ ## View the results
69
+
70
+ Once tiles are in a bucket, open the manifest in any IIIF viewer:
71
+
72
+ - **Mirador**: `https://projectmirador.org/embed/?iiif-content=https://huggingface.co/buckets/myorg/iiif-tiles/resolve/manifest.json`
73
+ - **Universal Viewer**: `https://uv-v4.netlify.app/#?manifest=https://huggingface.co/buckets/myorg/iiif-tiles/resolve/manifest.json`
74
+
75
+ ## Options
76
+
77
+ | Flag | Default | Description |
78
+ |------|---------|-------------|
79
+ | `--source-bucket` | — | HF bucket with source images (e.g., `org/source`) |
80
+ | `--source-dir` | — | Local directory with source images |
81
+ | `--output-bucket` | — | HF bucket for tiles (e.g., `org/tiles`) |
82
+ | `--output-dir` | — | Local directory for tiles |
83
+ | `--tile-size` | 512 | Tile size in pixels |
84
+ | `--base-url` | auto | Base URL for IIIF ids |
85
+ | `--collection-name` | "IIIF Collection" | Label for the manifest |
86
+ | `--workers` | 3 | Concurrent workers for bucket-to-bucket mode |
87
+
88
+ Supported image formats: JPEG, TIFF, PNG, WebP.
89
+
90
+ ## Performance
91
+
92
+ Bucket-to-bucket with 6 images (2411x3372 each), generating 54 tiles per image:
93
+
94
+ | Workers | Time | Local storage |
95
+ |---------|------|---------------|
96
+ | 1 | 14.3s | ~10MB (1 image + tiles) |
97
+ | 3 | 6.7s | ~30MB (3 images + tiles) |
98
+
99
+ Per image: ~0.6s download, ~0.2s tile, ~1.4s upload. The bottleneck is upload I/O, so concurrent workers overlap network time effectively.
100
+
101
+ ## What is IIIF Level 0?
102
+
103
+ [IIIF](https://iiif.io/) (International Image Interoperability Framework) is a set of APIs for serving and annotating images, widely used by libraries, archives, and museums. Level 0 means all tiles are pre-generated static files — no dynamic image server needed. Viewers request tiles that already exist on disk (or in a bucket).
104
+
105
+ This covers the primary use case: deep-zoom viewing of high-resolution scans. What you don't get (vs. a full IIIF server) is arbitrary cropping, rotation, or format conversion on the fly — but for browsing collections, Level 0 is all you need.
106
+
107
+ ## Why HF Storage Buckets?
108
+
109
+ - **Free hosting** for public buckets
110
+ - **Global CDN** with signed URLs
111
+ - **CORS support** for browser-based IIIF viewers
112
+ - **No infrastructure to maintain** — just static files
113
+ - **Streaming processing** — handles large collections without landing everything locally