Florent Gbelidji commited on
Sync DeepSeek OCR HF job code
Browse files- ds_batch_ocr/hf_io.py +1 -8
- ds_batch_ocr/stages.py +4 -4
ds_batch_ocr/hf_io.py
CHANGED
|
@@ -164,7 +164,7 @@ def maybe_upload_dataset(
|
|
| 164 |
"Add assembled DeepSeek OCR dataset " + datetime.utcnow().isoformat() + "Z"
|
| 165 |
)
|
| 166 |
|
| 167 |
-
token =
|
| 168 |
api = HfApi(token=token)
|
| 169 |
|
| 170 |
max_files = int(os.environ.get("HF_UPLOAD_CHUNK_MAX_FILES", DEFAULT_CHUNK_MAX_FILES))
|
|
@@ -216,13 +216,6 @@ def maybe_upload_dataset(
|
|
| 216 |
commit_message=message,
|
| 217 |
)
|
| 218 |
|
| 219 |
-
|
| 220 |
-
def env_or_none(name: str) -> Optional[str]:
|
| 221 |
-
value = os.environ.get(name)
|
| 222 |
-
if value:
|
| 223 |
-
value = value.strip()
|
| 224 |
-
return value or None
|
| 225 |
-
|
| 226 |
__all__ = [
|
| 227 |
"unpack_archives",
|
| 228 |
"download_job_artifact",
|
|
|
|
| 164 |
"Add assembled DeepSeek OCR dataset " + datetime.utcnow().isoformat() + "Z"
|
| 165 |
)
|
| 166 |
|
| 167 |
+
token = os.environ.get("HF_TOKEN", None)
|
| 168 |
api = HfApi(token=token)
|
| 169 |
|
| 170 |
max_files = int(os.environ.get("HF_UPLOAD_CHUNK_MAX_FILES", DEFAULT_CHUNK_MAX_FILES))
|
|
|
|
| 216 |
commit_message=message,
|
| 217 |
)
|
| 218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
__all__ = [
|
| 220 |
"unpack_archives",
|
| 221 |
"download_job_artifact",
|
ds_batch_ocr/stages.py
CHANGED
|
@@ -25,7 +25,7 @@ from .document import (
|
|
| 25 |
write_jsonl,
|
| 26 |
write_text,
|
| 27 |
)
|
| 28 |
-
from .hf_io import maybe_upload_dataset, resolve_stage_dir
|
| 29 |
|
| 30 |
LOGGER = logging.getLogger(__name__)
|
| 31 |
|
|
@@ -168,7 +168,7 @@ def _push_dataset_records(
|
|
| 168 |
|
| 169 |
dataset = Dataset.from_generator(_record_iterator, features=_dataset_features())
|
| 170 |
|
| 171 |
-
token =
|
| 172 |
dataset.push_to_hub(
|
| 173 |
repo_id=repo_id,
|
| 174 |
token=token,
|
|
@@ -834,7 +834,7 @@ def dataclass_to_dict(document: DocumentMetadata) -> Dict[str, Any]:
|
|
| 834 |
"document_markdown_text": document.document_markdown_text,
|
| 835 |
"document_final_markdown_path": document.document_final_markdown_path or "",
|
| 836 |
"document_final_markdown_text": document.document_final_markdown_text or "",
|
| 837 |
-
"
|
| 838 |
{
|
| 839 |
"figure_id": figure.figure_id,
|
| 840 |
"label": figure.label,
|
|
@@ -843,7 +843,7 @@ def dataclass_to_dict(document: DocumentMetadata) -> Dict[str, Any]:
|
|
| 843 |
"bounding_box_pixels": figure.bounding_box_pixels,
|
| 844 |
"description": figure.description or "",
|
| 845 |
}
|
| 846 |
-
for figure in document.
|
| 847 |
],
|
| 848 |
}
|
| 849 |
return result
|
|
|
|
| 25 |
write_jsonl,
|
| 26 |
write_text,
|
| 27 |
)
|
| 28 |
+
from .hf_io import maybe_upload_dataset, resolve_stage_dir
|
| 29 |
|
| 30 |
LOGGER = logging.getLogger(__name__)
|
| 31 |
|
|
|
|
| 168 |
|
| 169 |
dataset = Dataset.from_generator(_record_iterator, features=_dataset_features())
|
| 170 |
|
| 171 |
+
token = os.environ.get("HF_TOKEN", None)
|
| 172 |
dataset.push_to_hub(
|
| 173 |
repo_id=repo_id,
|
| 174 |
token=token,
|
|
|
|
| 834 |
"document_markdown_text": document.document_markdown_text,
|
| 835 |
"document_final_markdown_path": document.document_final_markdown_path or "",
|
| 836 |
"document_final_markdown_text": document.document_final_markdown_text or "",
|
| 837 |
+
"extracted_figures": [
|
| 838 |
{
|
| 839 |
"figure_id": figure.figure_id,
|
| 840 |
"label": figure.label,
|
|
|
|
| 843 |
"bounding_box_pixels": figure.bounding_box_pixels,
|
| 844 |
"description": figure.description or "",
|
| 845 |
}
|
| 846 |
+
for figure in document.extracted_figures
|
| 847 |
],
|
| 848 |
}
|
| 849 |
return result
|