Spaces:
Running on Zero
Running on Zero
Upload 2 files
Browse files- app.py +23 -0
- requirements.txt +6 -2
app.py
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# ---------------------------------------------------------------------------
|
| 2 |
# Plugin registration
|
| 3 |
# ---------------------------------------------------------------------------
|
|
|
|
| 1 |
+
# ---------------------------------------------------------------------------
|
| 2 |
+
# Force-upgrade transformers to >=5.1.0 before any other import.
|
| 3 |
+
#
|
| 4 |
+
# Why: PP-DocLayoutV3's custom model classes (PPDocLayoutV3ImageProcessor,
|
| 5 |
+
# PPDocLayoutV3ForObjectDetection) were added to the transformers library in
|
| 6 |
+
# version 5.1.0. docling-ibm-models caps transformers<5.0.0 (conservative
|
| 7 |
+
# pinning), so pip resolves transformers ~4.x at build time. We upgrade it
|
| 8 |
+
# here at runtime, before any docling/transformers import, so the correct
|
| 9 |
+
# classes are available. docling-ibm-models' usage (AutoModel, pipeline API)
|
| 10 |
+
# remains compatible with transformers 5.x.
|
| 11 |
+
# ---------------------------------------------------------------------------
|
| 12 |
+
import subprocess
|
| 13 |
+
import sys
|
| 14 |
+
|
| 15 |
+
subprocess.run(
|
| 16 |
+
[
|
| 17 |
+
sys.executable, "-m", "pip", "install",
|
| 18 |
+
"transformers>=5.1.0",
|
| 19 |
+
"--quiet",
|
| 20 |
+
],
|
| 21 |
+
check=True,
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
# ---------------------------------------------------------------------------
|
| 25 |
# Plugin registration
|
| 26 |
# ---------------------------------------------------------------------------
|
requirements.txt
CHANGED
|
@@ -1,6 +1,10 @@
|
|
| 1 |
# docling-pp-doc-layout is bundled as a local package (docling_pp_doc_layout/)
|
| 2 |
# because its PyPI releases require Python >=3.12 and ZeroGPU runs Python 3.10.
|
| 3 |
-
# Its dependencies are listed here directly
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
docling>=2.73
|
| 5 |
-
transformers
|
| 6 |
spaces
|
|
|
|
| 1 |
# docling-pp-doc-layout is bundled as a local package (docling_pp_doc_layout/)
|
| 2 |
# because its PyPI releases require Python >=3.12 and ZeroGPU runs Python 3.10.
|
| 3 |
+
# Its dependencies are listed here directly.
|
| 4 |
+
#
|
| 5 |
+
# transformers is intentionally NOT pinned here. docling-ibm-models caps it
|
| 6 |
+
# at <5.0.0, so pip resolves ~4.x at build time. app.py then force-upgrades
|
| 7 |
+
# to >=5.1.0 at runtime (before any imports) because PP-DocLayoutV3's custom
|
| 8 |
+
# classes were added to transformers in 5.1.0.
|
| 9 |
docling>=2.73
|
|
|
|
| 10 |
spaces
|