Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,7 +42,7 @@ def convert_to_pil(image_input: str) -> Image.Image:
|
|
| 42 |
raise ValueError(f"Could not convert image input to PIL.Image: {type(image_input)}")
|
| 43 |
|
| 44 |
|
| 45 |
-
def smoldocling_readimage(image:
|
| 46 |
"""
|
| 47 |
Extract text and structured content from document images using SmolDocling model.
|
| 48 |
|
|
@@ -51,8 +51,7 @@ def smoldocling_readimage(image: str, prompt_text: str) -> str:
|
|
| 51 |
the SmolDocling-256M-preview model for image-to-text conversion with chat-based prompting.
|
| 52 |
|
| 53 |
Args:
|
| 54 |
-
image (
|
| 55 |
-
MCP clients will send this as base64.
|
| 56 |
prompt_text (str): The instruction or prompt text that guides the model's output format.
|
| 57 |
Supported prompts include:
|
| 58 |
|
|
@@ -86,7 +85,7 @@ def smoldocling_readimage(image: str, prompt_text: str) -> str:
|
|
| 86 |
- Maximum output length is limited to 1024 new tokens
|
| 87 |
"""
|
| 88 |
# Convert string input (base64 or path) to PIL.Image
|
| 89 |
-
pil_image = convert_to_pil(image)
|
| 90 |
|
| 91 |
messages = [
|
| 92 |
{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": prompt_text}]}
|
|
|
|
| 42 |
raise ValueError(f"Could not convert image input to PIL.Image: {type(image_input)}")
|
| 43 |
|
| 44 |
|
| 45 |
+
def smoldocling_readimage(image: Image.Image, prompt_text: str) -> str:
|
| 46 |
"""
|
| 47 |
Extract text and structured content from document images using SmolDocling model.
|
| 48 |
|
|
|
|
| 51 |
the SmolDocling-256M-preview model for image-to-text conversion with chat-based prompting.
|
| 52 |
|
| 53 |
Args:
|
| 54 |
+
image (Image.Image): The input document image
|
|
|
|
| 55 |
prompt_text (str): The instruction or prompt text that guides the model's output format.
|
| 56 |
Supported prompts include:
|
| 57 |
|
|
|
|
| 85 |
- Maximum output length is limited to 1024 new tokens
|
| 86 |
"""
|
| 87 |
# Convert string input (base64 or path) to PIL.Image
|
| 88 |
+
# pil_image = convert_to_pil(image)
|
| 89 |
|
| 90 |
messages = [
|
| 91 |
{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": prompt_text}]}
|