Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -109,17 +109,19 @@ async def extract_text(file: UploadFile = File(...)):
|
|
| 109 |
{
|
| 110 |
"role": "user",
|
| 111 |
"content": [
|
| 112 |
-
{"type": "image"},
|
| 113 |
{"type": "text", "text": "Extract all text from this image."}
|
| 114 |
],
|
| 115 |
}
|
| 116 |
]
|
| 117 |
|
|
|
|
|
|
|
| 118 |
# 2. Use the chat template to prepare inputs
|
| 119 |
# This fixes the 'NoneType' error by providing valid input_ids
|
| 120 |
inputs = processor.apply_chat_template(
|
| 121 |
messages,
|
| 122 |
-
|
| 123 |
tokenize=True,
|
| 124 |
add_generation_prompt=True,
|
| 125 |
return_dict=True,
|
|
|
|
| 109 |
{
|
| 110 |
"role": "user",
|
| 111 |
"content": [
|
| 112 |
+
{"type": "image", "image": image},
|
| 113 |
{"type": "text", "text": "Extract all text from this image."}
|
| 114 |
],
|
| 115 |
}
|
| 116 |
]
|
| 117 |
|
| 118 |
+
|
| 119 |
+
|
| 120 |
# 2. Use the chat template to prepare inputs
|
| 121 |
# This fixes the 'NoneType' error by providing valid input_ids
|
| 122 |
inputs = processor.apply_chat_template(
|
| 123 |
messages,
|
| 124 |
+
|
| 125 |
tokenize=True,
|
| 126 |
add_generation_prompt=True,
|
| 127 |
return_dict=True,
|