sparrow-parse 1.0.7__tar.gz → 1.0.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/PKG-INFO +1 -1
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/setup.py +1 -1
- sparrow-parse-1.0.8/sparrow_parse/__init__.py +1 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse/vllm/mlx_inference.py +43 -17
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse.egg-info/PKG-INFO +1 -1
- sparrow-parse-1.0.7/sparrow_parse/__init__.py +0 -1
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/README.md +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/setup.cfg +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse/__main__.py +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse/extractors/__init__.py +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse/extractors/vllm_extractor.py +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse/helpers/__init__.py +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse/helpers/image_optimizer.py +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse/helpers/pdf_optimizer.py +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse/processors/__init__.py +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse/processors/table_structure_processor.py +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse/text_extraction.py +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse/vllm/__init__.py +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse/vllm/huggingface_inference.py +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse/vllm/inference_base.py +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse/vllm/inference_factory.py +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse/vllm/local_gpu_inference.py +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse.egg-info/SOURCES.txt +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse.egg-info/dependency_links.txt +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse.egg-info/entry_points.txt +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse.egg-info/requires.txt +0 -0
- {sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: sparrow-parse
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.8
|
4
4
|
Summary: Sparrow Parse is a Python package (part of Sparrow) for parsing and extracting information from documents.
|
5
5
|
Home-page: https://github.com/katanaml/sparrow/tree/main/sparrow-data/parse
|
6
6
|
Author: Andrej Baranovskij
|
@@ -8,7 +8,7 @@ with open("requirements.txt", "r", encoding="utf-8") as fh:
|
|
8
8
|
|
9
9
|
setup(
|
10
10
|
name="sparrow-parse",
|
11
|
-
version="1.0.
|
11
|
+
version="1.0.8",
|
12
12
|
author="Andrej Baranovskij",
|
13
13
|
author_email="andrejus.baranovskis@gmail.com",
|
14
14
|
description="Sparrow Parse is a Python package (part of Sparrow) for parsing and extracting information from documents.",
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = '1.0.8'
|
@@ -75,7 +75,6 @@ class MLXInference(ModelInference):
|
|
75
75
|
print(f"Failed to parse JSON: {e}")
|
76
76
|
return output_text
|
77
77
|
|
78
|
-
|
79
78
|
def load_image_data(self, image_filepath, max_width=1250, max_height=1750):
|
80
79
|
"""
|
81
80
|
Load and resize image while maintaining its aspect ratio.
|
@@ -155,7 +154,8 @@ class MLXInference(ModelInference):
|
|
155
154
|
def _process_images(self, model, processor, config, file_paths, input_data, apply_annotation):
|
156
155
|
"""
|
157
156
|
Process images and generate responses for each.
|
158
|
-
|
157
|
+
If apply_annotation=True, don't resize to maintain accurate coordinates.
|
158
|
+
|
159
159
|
:param model: The loaded model
|
160
160
|
:param processor: The loaded processor
|
161
161
|
:param config: Model configuration
|
@@ -166,28 +166,54 @@ class MLXInference(ModelInference):
|
|
166
166
|
"""
|
167
167
|
results = []
|
168
168
|
for file_path in file_paths:
|
169
|
-
image
|
170
|
-
|
169
|
+
# Load image differently based on annotation requirement
|
170
|
+
if apply_annotation:
|
171
|
+
# For annotation, just load the image without resizing
|
172
|
+
image = load_image(file_path)
|
173
|
+
# We'll skip the resize_shape parameter when generating
|
174
|
+
else:
|
175
|
+
# For non-annotation cases, load with potential resizing
|
176
|
+
image, width, height = self.load_image_data(file_path)
|
177
|
+
# We'll use resize_shape when generating
|
178
|
+
|
171
179
|
# Prepare messages based on model type
|
172
180
|
messages = self._prepare_messages(input_data, apply_annotation)
|
173
|
-
|
181
|
+
|
174
182
|
# Generate and process response
|
175
183
|
prompt = apply_chat_template(processor, config, messages)
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
184
|
+
|
185
|
+
if apply_annotation:
|
186
|
+
# When annotation is required, don't use resize_shape
|
187
|
+
# This preserves original coordinate system
|
188
|
+
response, _ = generate(
|
189
|
+
model,
|
190
|
+
processor,
|
191
|
+
prompt,
|
192
|
+
image,
|
193
|
+
max_tokens=4000,
|
194
|
+
temperature=0.0,
|
195
|
+
verbose=False
|
196
|
+
)
|
197
|
+
else:
|
198
|
+
# For non-annotation cases, use resize_shape for memory efficiency
|
199
|
+
response, _ = generate(
|
200
|
+
model,
|
201
|
+
processor,
|
202
|
+
prompt,
|
203
|
+
image,
|
204
|
+
resize_shape=(width, height),
|
205
|
+
max_tokens=4000,
|
206
|
+
temperature=0.0,
|
207
|
+
verbose=False
|
208
|
+
)
|
209
|
+
|
210
|
+
processed_response = self.process_response(response)
|
211
|
+
results.append(processed_response)
|
187
212
|
print(f"Inference completed successfully for: {file_path}")
|
188
|
-
|
213
|
+
|
189
214
|
return results
|
190
215
|
|
216
|
+
|
191
217
|
def transform_query_with_bbox(self, text_input):
|
192
218
|
"""
|
193
219
|
Transform JSON schema in text_input to include value, bbox, and confidence.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: sparrow-parse
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.8
|
4
4
|
Summary: Sparrow Parse is a Python package (part of Sparrow) for parsing and extracting information from documents.
|
5
5
|
Home-page: https://github.com/katanaml/sparrow/tree/main/sparrow-data/parse
|
6
6
|
Author: Andrej Baranovskij
|
@@ -1 +0,0 @@
|
|
1
|
-
__version__ = '1.0.7'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{sparrow-parse-1.0.7 → sparrow-parse-1.0.8}/sparrow_parse/processors/table_structure_processor.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|