Commit
·
e69f406
1
Parent(s):
a9bc1eb
Fix output_path parameter in model.infer
Browse filesAdd temp_output directory and pass real path instead of empty string:
- Create temp_output/ directory
- Pass to model.infer as output_path parameter
- Clean up both temp directories at end
The model expects a real directory path, not empty string.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- deepseek-ocr.py +9 -3
deepseek-ocr.py
CHANGED
|
@@ -201,6 +201,7 @@ def process_single_image(
|
|
| 201 |
image_size: int,
|
| 202 |
crop_mode: bool,
|
| 203 |
temp_image_path: str,
|
|
|
|
| 204 |
) -> str:
|
| 205 |
"""Process a single image through DeepSeek-OCR."""
|
| 206 |
# Convert to RGB if needed
|
|
@@ -215,7 +216,7 @@ def process_single_image(
|
|
| 215 |
tokenizer,
|
| 216 |
prompt=prompt,
|
| 217 |
image_file=temp_image_path,
|
| 218 |
-
output_path=
|
| 219 |
base_size=base_size,
|
| 220 |
image_size=image_size,
|
| 221 |
crop_mode=crop_mode,
|
|
@@ -333,11 +334,14 @@ 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
|
| 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"):
|
| 343 |
try:
|
|
@@ -362,6 +366,7 @@ def main(
|
|
| 362 |
final_image_size,
|
| 363 |
final_crop_mode,
|
| 364 |
temp_image_path,
|
|
|
|
| 365 |
)
|
| 366 |
|
| 367 |
all_markdown.append(result)
|
|
@@ -371,9 +376,10 @@ def main(
|
|
| 371 |
all_markdown.append("[OCR FAILED]")
|
| 372 |
|
| 373 |
finally:
|
| 374 |
-
# Clean up temp
|
| 375 |
try:
|
| 376 |
shutil.rmtree(temp_dir)
|
|
|
|
| 377 |
except:
|
| 378 |
pass
|
| 379 |
|
|
|
|
| 201 |
image_size: int,
|
| 202 |
crop_mode: bool,
|
| 203 |
temp_image_path: str,
|
| 204 |
+
temp_output_dir: str,
|
| 205 |
) -> str:
|
| 206 |
"""Process a single image through DeepSeek-OCR."""
|
| 207 |
# Convert to RGB if needed
|
|
|
|
| 216 |
tokenizer,
|
| 217 |
prompt=prompt,
|
| 218 |
image_file=temp_image_path,
|
| 219 |
+
output_path=temp_output_dir, # Need real directory path
|
| 220 |
base_size=base_size,
|
| 221 |
image_size=image_size,
|
| 222 |
crop_mode=crop_mode,
|
|
|
|
| 334 |
logger.info(f"Processing {len(dataset)} images (sequential, no batching)")
|
| 335 |
logger.info("Note: This may be slower than vLLM-based scripts")
|
| 336 |
|
| 337 |
+
# Create temp directories for image files and output (simple local dirs)
|
| 338 |
temp_dir = Path("temp_images")
|
| 339 |
temp_dir.mkdir(exist_ok=True)
|
| 340 |
temp_image_path = str(temp_dir / "temp_image.png")
|
| 341 |
|
| 342 |
+
temp_output_dir = Path("temp_output")
|
| 343 |
+
temp_output_dir.mkdir(exist_ok=True)
|
| 344 |
+
|
| 345 |
try:
|
| 346 |
for i in tqdm(range(len(dataset)), desc="OCR processing"):
|
| 347 |
try:
|
|
|
|
| 366 |
final_image_size,
|
| 367 |
final_crop_mode,
|
| 368 |
temp_image_path,
|
| 369 |
+
str(temp_output_dir),
|
| 370 |
)
|
| 371 |
|
| 372 |
all_markdown.append(result)
|
|
|
|
| 376 |
all_markdown.append("[OCR FAILED]")
|
| 377 |
|
| 378 |
finally:
|
| 379 |
+
# Clean up temp directories
|
| 380 |
try:
|
| 381 |
shutil.rmtree(temp_dir)
|
| 382 |
+
shutil.rmtree(temp_output_dir)
|
| 383 |
except:
|
| 384 |
pass
|
| 385 |
|