davanstrien HF Staff Claude commited on
Commit
a9bc1eb
·
1 Parent(s): 123f376

Use local temp_images directory instead of system temp

Browse files

Replace tempfile.mkdtemp() with simple local directory:
- Create "temp_images" in current working directory
- More reliable in containerized environments like HF Jobs
- Simpler and easier to debug

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Files changed (1) hide show
  1. deepseek-ocr.py +5 -4
deepseek-ocr.py CHANGED
@@ -42,8 +42,8 @@ import logging
42
  import os
43
  import shutil
44
  import sys
45
- import tempfile
46
  from datetime import datetime
 
47
  from typing import Optional
48
 
49
  import torch
@@ -333,9 +333,10 @@ def main(
333
  logger.info(f"Processing {len(dataset)} images (sequential, no batching)")
334
  logger.info("Note: This may be slower than vLLM-based scripts")
335
 
336
- # Create temp directory for image files
337
- temp_dir = tempfile.mkdtemp()
338
- temp_image_path = os.path.join(temp_dir, "temp_image.png")
 
339
 
340
  try:
341
  for i in tqdm(range(len(dataset)), desc="OCR processing"):
 
42
  import os
43
  import shutil
44
  import sys
 
45
  from datetime import datetime
46
+ from pathlib import Path
47
  from typing import Optional
48
 
49
  import torch
 
333
  logger.info(f"Processing {len(dataset)} images (sequential, no batching)")
334
  logger.info("Note: This may be slower than vLLM-based scripts")
335
 
336
+ # Create temp directory for image files (simple local dir)
337
+ temp_dir = Path("temp_images")
338
+ temp_dir.mkdir(exist_ok=True)
339
+ temp_image_path = str(temp_dir / "temp_image.png")
340
 
341
  try:
342
  for i in tqdm(range(len(dataset)), desc="OCR processing"):