"...git@developer.sourcefind.cn:OpenDAS/mmdetection3d.git" did not exist on "7f4bb54d8d7201bbef5eb9c700fe59bfe9e6dd49"
Commit b1adde8e authored by icecraft's avatar icecraft
Browse files

fix: rewrite projects/ and demos with new data api

parent 4e0b3a8f
import os import os
from loguru import logger from loguru import logger
from magic_pdf.pipe.UNIPipe import UNIPipe
from magic_pdf.rw.DiskReaderWriter import DiskReaderWriter
from magic_pdf.data.data_reader_writer import FileBasedDataWriter
from magic_pdf.pipe.UNIPipe import UNIPipe
try: try:
current_script_dir = os.path.dirname(os.path.abspath(__file__)) current_script_dir = os.path.dirname(os.path.abspath(__file__))
demo_name = "demo1" demo_name = 'demo1'
pdf_path = os.path.join(current_script_dir, f"{demo_name}.pdf") pdf_path = os.path.join(current_script_dir, f'{demo_name}.pdf')
pdf_bytes = open(pdf_path, "rb").read() pdf_bytes = open(pdf_path, 'rb').read()
jso_useful_key = {"_pdf_type": "", "model_list": []} jso_useful_key = {'_pdf_type': '', 'model_list': []}
local_image_dir = os.path.join(current_script_dir, 'images') local_image_dir = os.path.join(current_script_dir, 'images')
image_dir = str(os.path.basename(local_image_dir)) image_dir = str(os.path.basename(local_image_dir))
image_writer = DiskReaderWriter(local_image_dir) image_writer = FileBasedDataWriter(local_image_dir)
pipe = UNIPipe(pdf_bytes, jso_useful_key, image_writer) pipe = UNIPipe(pdf_bytes, jso_useful_key, image_writer)
pipe.pipe_classify() pipe.pipe_classify()
pipe.pipe_analyze() pipe.pipe_analyze()
pipe.pipe_parse() pipe.pipe_parse()
md_content = pipe.pipe_mk_markdown(image_dir, drop_mode="none") md_content = pipe.pipe_mk_markdown(image_dir, drop_mode='none')
with open(f"{demo_name}.md", "w", encoding="utf-8") as f: with open(f'{demo_name}.md', 'w', encoding='utf-8') as f:
f.write(md_content) f.write(md_content)
except Exception as e: except Exception as e:
logger.exception(e) logger.exception(e)
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment