Spaces:
				
			
			
	
			
			
		Running
		
			on 
			
			Zero
	
	
	
			
			
	
	
	
	
		
		
		Running
		
			on 
			
			Zero
	update load_from_doctags usage
Browse files
    	
        app.py
    CHANGED
    
    | 
         @@ -124,13 +124,12 @@ def model_inference( 
     | 
|
| 124 | 
         
             
                    yield cleaned_output
         
     | 
| 125 | 
         | 
| 126 | 
         
             
                if any(tag in doctag_output for tag in ["<doctag>", "<otsl>", "<code>", "<chart>", "<formula>"]):
         
     | 
| 127 | 
         
            -
                    doc = DoclingDocument(name="Document")
         
     | 
| 128 | 
         
             
                    if "<chart>" in doctag_output:
         
     | 
| 129 | 
         
             
                        doctag_output = doctag_output.replace("<chart>", "<otsl>").replace("</chart>", "</otsl>")
         
     | 
| 130 | 
         
             
                        doctag_output = re.sub(r'(<loc_500>)(?!.*<loc_500>)<[^>]+>', r'\1', doctag_output)
         
     | 
| 131 | 
         | 
| 132 | 
         
             
                    doctags_doc = DocTagsDocument.from_doctags_and_image_pairs([doctag_output], images)
         
     | 
| 133 | 
         
            -
                    doc.load_from_doctags(doctags_doc)
         
     | 
| 134 | 
         
             
                    yield f"**MD Output:**\n\n{doc.export_to_markdown()}"
         
     | 
| 135 | 
         | 
| 136 | 
         
             
            examples=[[{"text": "Convert this page to docling.", "files": ["example_images/2d0fbcc50e88065a040a537b717620e964fb4453314b71d83f3ed3425addcef6.png"]}],
         
     | 
| 
         | 
|
| 124 | 
         
             
                    yield cleaned_output
         
     | 
| 125 | 
         | 
| 126 | 
         
             
                if any(tag in doctag_output for tag in ["<doctag>", "<otsl>", "<code>", "<chart>", "<formula>"]):
         
     | 
| 
         | 
|
| 127 | 
         
             
                    if "<chart>" in doctag_output:
         
     | 
| 128 | 
         
             
                        doctag_output = doctag_output.replace("<chart>", "<otsl>").replace("</chart>", "</otsl>")
         
     | 
| 129 | 
         
             
                        doctag_output = re.sub(r'(<loc_500>)(?!.*<loc_500>)<[^>]+>', r'\1', doctag_output)
         
     | 
| 130 | 
         | 
| 131 | 
         
             
                    doctags_doc = DocTagsDocument.from_doctags_and_image_pairs([doctag_output], images)
         
     | 
| 132 | 
         
            +
                    doc = DoclingDocument.load_from_doctags(doctags_doc, document_name="Document")
         
     | 
| 133 | 
         
             
                    yield f"**MD Output:**\n\n{doc.export_to_markdown()}"
         
     | 
| 134 | 
         | 
| 135 | 
         
             
            examples=[[{"text": "Convert this page to docling.", "files": ["example_images/2d0fbcc50e88065a040a537b717620e964fb4453314b71d83f3ed3425addcef6.png"]}],
         
     |