Skip to content

Commit f8ea629

Browse files
committed
parse image resposeDocument compatible - Adithya S K
1 parent d5c7827 commit f8ea629

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

omniparse/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def load_omnimodel(load_documents: bool, load_media: bool, load_web: bool):
2323
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
2424
if load_documents:
2525
print("[LOG] ✅ Loading OCR Model")
26-
# shared_state.model_list = load_all_models()
26+
shared_state.model_list = load_all_models()
2727
print("[LOG] ✅ Loading Vision Model")
2828
# if device == "cuda":
2929
shared_state.vision_model = AutoModelForCausalLM.from_pretrained('microsoft/Florence-2-base', trust_remote_code=True).to(device)

omniparse/image/router.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
async def parse_image_endpoint(file: UploadFile = File(...)):
1212
try:
1313
file_bytes = await file.read()
14-
result = parse_image(file_bytes, model_state)
15-
return JSONResponse(content=result)
14+
result : responseDocument = parse_image(file_bytes, model_state)
15+
return JSONResponse(content=result.model_dump())
1616

1717
except Exception as e:
1818
raise HTTPException(status_code=500, detail=str(e))

omniparse/utils.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from omniparse.models import responseDocument
55

66
def encode_images(images, inputDocument:responseDocument):
7-
image_data = []
87
for i, (filename, image) in enumerate(images.items()):
98
# print(f"Processing image {filename}")
109
# Save image as PNG
@@ -14,13 +13,11 @@ def encode_images(images, inputDocument:responseDocument):
1413
image_bytes = f.read()
1514
# Convert image to base64
1615
image_base64 = base64.b64encode(image_bytes).decode('utf-8')
17-
image_data[f'{filename}'] = image_base64
1816

1917
inputDocument.add_image(image_name=filename,image_data=image_base64)
2018

2119
# Remove the temporary image file
2220
os.remove(filename)
23-
return image_data
2421

2522

2623
def print_omniparse_text_art(suffix=None):

0 commit comments

Comments
 (0)