How to switch output

#3
by jarrettsorensen - opened

Hello,

I'm new to this space, so forgive me if this sounds simple, but I don't understand how to switch between the xml and json output when using this model. I've successfully run the model with an image and received xml output, but I'd like to use the json output, and I don't know how to tell it to output json instead of xml

hi,
Current JSON output is using XML result as input in DONUT model.

please see my example notebook - section 4. here: (https://github.com/minyang-chen/LLM_convert_receipt_image-to-json_or_xml/blob/main/Convert%20Receipt%20Image-to-strucuture_data%20using_donut_model-German.ipynb)

Section#4

def generateOutputJson(processor,model, input_image, task_start="<s_receipt>",task_end="</s_receipt>"):
    xml = generateOutputXML(processor,model, input_image,task_start=task_start,task_end=task_end)
    result=processor.token2json(xml)
    print(":vampire:",result)
    return result

## generate json
invoice1_json=generateOutputJson(processor,model,input_image)
print(invoice1_json)

hope this help!

Sign up or log in to comment