Upload 3 files
Browse files- README.md +20 -23
- requirements.txt +3 -2
README.md
CHANGED
|
@@ -4,39 +4,36 @@ emoji: 📄
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
|
|
|
|
|
|
| 7 |
app_file: app.py
|
| 8 |
pinned: false
|
| 9 |
---
|
|
|
|
| 10 |
# DeepSeek-OCR full-page CSV Space
|
| 11 |
|
| 12 |
-
This
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
##
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
-
- Variable `OCR_PROFILE`: `gundam` (recommended for small text), `small`, `tiny`, `base`, or `large`.
|
| 22 |
-
- Variable `GPU_DURATION_SECONDS`: `180` is the requested default; ZeroGPU must allow the request and you need enough remaining quota. If ZeroGPU reports an illegal duration, lower it to a permitted value. If it says quota exceeded, changing the number alone will not restore quota.
|
| 23 |
|
| 24 |
-
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
| 29 |
-
2. Replace it with this package's `app.py`.
|
| 30 |
-
3. Update `requirements.txt` from this package if needed.
|
| 31 |
-
4. Save/commit the files and let the Space rebuild.
|
| 32 |
-
5. Test the Gradio UI with one representative full-page image.
|
| 33 |
-
6. In Telegram, send the image as a **document/file** (not a compressed photo) to preserve resolution.
|
| 34 |
-
7. Check the downloaded CSV against the page before using it.
|
| 35 |
|
| 36 |
-
##
|
| 37 |
|
| 38 |
-
|
| 39 |
-
- CSV columns: `voter_id`, `name`, `relative_type`, `relative_name`, `house_number`, `age`, `gender`, `photo_status`.
|
| 40 |
-
- OCR and visual grouping remain heuristic. Always manually review the voter ID/name association and any incomplete row.
|
| 41 |
-
- The code prevents duplicate Telegram polling starts inside one Python process. If Telegram logs `Conflict: terminated by other getUpdates request`, another running process/Space is still using the same bot token. Only one polling instance can use that token at a time.
|
| 42 |
-
- If a bot token was exposed in logs or chat, revoke it with BotFather and update the Space secret.
|
|
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 5.49.1
|
| 8 |
+
python_version: "3.10"
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
---
|
| 12 |
+
|
| 13 |
# DeepSeek-OCR full-page CSV Space
|
| 14 |
|
| 15 |
+
This Space runs `strangervisionhf/deepseek-ocr-transformers-v4.57.6`, provides full-page OCR, CSV preview/download, and an optional Telegram polling bot.
|
| 16 |
+
|
| 17 |
+
## Configuration
|
| 18 |
+
|
| 19 |
+
In **Settings → Variables and secrets**, set:
|
| 20 |
+
|
| 21 |
+
- Secret `TELEGRAM_BOT_TOKEN`: your Telegram bot token. Do not put it in source files. If a token has been exposed, revoke it with BotFather and replace this secret.
|
| 22 |
+
- Variable `OCR_PROFILE`: `gundam`, `small`, or `tiny`.
|
| 23 |
+
- Variable `GPU_DURATION_SECONDS`: requested GPU reservation duration. The platform's allowed duration/quota still applies.
|
| 24 |
|
| 25 |
+
## Install these files
|
| 26 |
|
| 27 |
+
Keep `README.md`, `requirements.txt`, and `app.py` in the **root** of the Space repository. Commit them together, then use **Factory Rebuild** so the SDK version in this README is applied.
|
| 28 |
|
| 29 |
+
The Gradio version is selected here by `sdk_version`. Do not add a separate `gradio` line to `requirements.txt`.
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
## CSV fields
|
| 32 |
|
| 33 |
+
`voter_id`, `name`, `relative_type`, `relative_name`, `house_number`, `age`, `gender`, `photo_status`
|
| 34 |
|
| 35 |
+
OCR and grouping may be imperfect. Review the output CSV against the source image before relying on it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
## Telegram
|
| 38 |
|
| 39 |
+
Only one active polling process can use a bot token at a time. If logs show `Conflict: terminated by other getUpdates request`, stop other processes or Spaces using the same token.
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
#
|
| 2 |
transformers==4.57.6
|
| 3 |
tokenizers==0.22.2
|
| 4 |
accelerate>=0.33,<2.0
|
|
@@ -14,4 +14,5 @@ pillow>=10,<12
|
|
| 14 |
pymupdf
|
| 15 |
python-telegram-bot>=22.0,<23.0
|
| 16 |
httpx>=0.27,<1.0
|
| 17 |
-
huggingface-hub>=0.34.0,<1.0
|
|
|
|
|
|
| 1 |
+
# Gradio is provided by the Space SDK version in README.md (5.49.1).
|
| 2 |
transformers==4.57.6
|
| 3 |
tokenizers==0.22.2
|
| 4 |
accelerate>=0.33,<2.0
|
|
|
|
| 14 |
pymupdf
|
| 15 |
python-telegram-bot>=22.0,<23.0
|
| 16 |
httpx>=0.27,<1.0
|
| 17 |
+
huggingface-hub>=0.34.0,<1.0
|
| 18 |
+
spaces>=0.30.0
|