davanstrien HF Staff commited on
Commit
daa5aea
·
verified ·
1 Parent(s): 180d945

Sync from GitHub via hub-sync

Browse files
Files changed (2) hide show
  1. README.md +6 -3
  2. glm-ocr.py +7 -4
README.md CHANGED
@@ -18,12 +18,15 @@ First, [install the `hf` CLI and sign in](https://huggingface.co/docs/hub/jobs-q
18
  Try [GLM-OCR](https://huggingface.co/zai-org/GLM-OCR) on seven scanned pages from [NASA’s *Food for Space Flight* booklet](https://huggingface.co/datasets/uv-scripts/ocr-demo). Replace `your-username` with your Hugging Face username:
19
 
20
  ```bash
21
- hf jobs uv run --flavor a10g-small --timeout 15m --secrets HF_TOKEN \
22
- https://huggingface.co/datasets/uv-scripts/ocr/raw/main/glm-ocr.py \
23
  uv-scripts/ocr-demo your-username/ocr-demo-results
24
  ```
25
 
26
- The Job adds a `markdown` column to all seven rows and saves them in `your-username/ocr-demo-results`. Dependency installation and model loading can take a few minutes before OCR starts. The [dataset card](https://huggingface.co/datasets/uv-scripts/ocr-demo) documents the source and licence. Check the extracted text against the originals, especially tables and reading order.
 
 
 
 
27
 
28
  ### Try the same pages as a PDF
29
 
 
18
  Try [GLM-OCR](https://huggingface.co/zai-org/GLM-OCR) on seven scanned pages from [NASA’s *Food for Space Flight* booklet](https://huggingface.co/datasets/uv-scripts/ocr-demo). Replace `your-username` with your Hugging Face username:
19
 
20
  ```bash
21
+ hf jobs uv run https://huggingface.co/datasets/uv-scripts/ocr/raw/main/glm-ocr.py \
 
22
  uv-scripts/ocr-demo your-username/ocr-demo-results
23
  ```
24
 
25
+ The script declares its hardware (`a10g-small`) and the `HF_TOKEN` secret in a
26
+ [`[tool.hf-jobs]` header](https://huggingface.co/docs/hub/jobs-configuration#define-the-launch-config-in-the-script)
27
+ (`hf` CLI 1.32 or newer reads it; `hf jobs uv run --dry-run <script>` shows the resolved
28
+ configuration). Flags still win, so add `--timeout 1h` for a larger dataset or `--flavor` to
29
+ change hardware. The Job adds a `markdown` column to all seven rows and saves them in `your-username/ocr-demo-results`. Dependency installation and model loading can take a few minutes before OCR starts. The [dataset card](https://huggingface.co/datasets/uv-scripts/ocr-demo) documents the source and licence. Check the extracted text against the originals, especially tables and reading order.
30
 
31
  ### Try the same pages as a PDF
32
 
glm-ocr.py CHANGED
@@ -15,6 +15,10 @@
15
  # [tool.uv]
16
  # prerelease = "allow"
17
  # override-dependencies = ["transformers>=5.1.0"]
 
 
 
 
18
  # ///
19
 
20
  """
@@ -527,11 +531,10 @@ if __name__ == "__main__":
527
  print(" uv run glm-ocr.py docs results --task table")
528
  print("\n4. Test with small sample:")
529
  print(" uv run glm-ocr.py large-dataset test --max-samples 10 --shuffle")
530
- print("\n5. Running on HF Jobs:")
531
- print(" hf jobs uv run --flavor l4x1 \\")
532
- print(" -s HF_TOKEN \\")
533
  print(
534
- " https://huggingface.co/datasets/uv-scripts/ocr/raw/main/glm-ocr.py \\"
535
  )
536
  print(" input-dataset output-dataset --batch-size 16")
537
  print("\nFor full help: uv run glm-ocr.py --help")
 
15
  # [tool.uv]
16
  # prerelease = "allow"
17
  # override-dependencies = ["transformers>=5.1.0"]
18
+ #
19
+ # [tool.hf-jobs]
20
+ # flavor = "a10g-small"
21
+ # secrets = ["HF_TOKEN"]
22
  # ///
23
 
24
  """
 
531
  print(" uv run glm-ocr.py docs results --task table")
532
  print("\n4. Test with small sample:")
533
  print(" uv run glm-ocr.py large-dataset test --max-samples 10 --shuffle")
534
+ print("\n5. Running on HF Jobs (hardware and HF_TOKEN come from the")
535
+ print(" script's [tool.hf-jobs] header; --flavor/--timeout override it):")
 
536
  print(
537
+ " hf jobs uv run https://huggingface.co/datasets/uv-scripts/ocr/raw/main/glm-ocr.py \\"
538
  )
539
  print(" input-dataset output-dataset --batch-size 16")
540
  print("\nFor full help: uv run glm-ocr.py --help")