แพ็คเกจ Python สำหรับการแปลง PDFs (หรือ URL PDF) เป็น markdown ในขณะที่แยกรูปภาพและตาราง Markdrop ทำให้ง่ายต่อการแปลงเอกสาร PDF เป็นรูปแบบ Markdown ในขณะที่รักษาภาพและตาราง
pip install markdrop https://pypi.org/project/markdrop
from markdrop import extract_images , make_markdown , extract_tables_from_pdf
source_pdf = 'url/or/path/to/pdf/file' # Replace with your local PDF file path or a URL
output_dir = 'data/output' # Replace it with desired output directory's path
make_markdown ( source_pdf , output_dir )
extract_images ( source_pdf , output_dir , verbose = True )
extract_tables_from_pdf ( source_pdf , output_dir = output_dir ) from markdrop import setup_keys
### API Key Setup
### If using 'openai' or 'gemini' as llm_client in the generate_descriptions function, you need to set up the API keys first.
setup_keys () from markdrop import generate_descriptions
### Image Descriptions Generation
prompt = "Give textual highly detailed descriptions from this image ONLY, nothing else." # Replace it with your desired prompt
input_path = 'path/to/img_file/or/dir' # Replace it with the path to the images dir or image file
output_dir = 'data/output' # Replace it with the desired output directory's path
llm_clients = [ 'gemini' , 'llama-vision' ] # Replace it with the desired models from ['qwen', 'gemini', 'openai', 'llama-vision', 'molmo', 'pixtral'] only
generate_descriptions ( input_path = input_path , output_dir = output_dir , prompt = prompt , llm_client = llm_clients )แปลง PDF หรือ URL เป็นรูปแบบ markdown
พารามิเตอร์:
source (STR): เส้นทางไปยัง PDF หรือ URLoutput_dir (STR): เส้นทางไดเรกทอรีเอาต์พุตverbose (บูล): เปิดใช้งานการบันทึกรายละเอียดแยกภาพจาก PDF หรือ URL ในขณะที่รักษาคุณภาพ
พารามิเตอร์:
source (STR): เส้นทางไปยัง PDF หรือ URLoutput_dir (STR): เส้นทางไดเรกทอรีเอาต์พุตverbose (บูล): เปิดใช้งานการบันทึกรายละเอียดตรวจจับและแยกภาพตาราง
พารามิเตอร์:
pdf_path (str): เส้นทางไปยังอินพุต pdf หรือ urlstart_page (int, ไม่บังคับ): หมายเลขหน้าเริ่มต้นend_page (int, ไม่บังคับ): หมายเลขหน้าสิ้นสุดthreshold (Float, เสริม): Threshold ความเชื่อมั่นในการตรวจจับoutput_dir (STR): เส้นทางไดเรกทอรีเอาต์พุตสร้างคำอธิบายของภาพตามพรอมต์ที่กำหนดและ llm_client ใน CSV
llm clientsได้รับการสนับสนุนคือ ['Qwen', 'Gemini', 'Openai', 'Llama-Vision', 'Molmo', 'Pixtral']
พารามิเตอร์:
input_path (str): เส้นทางไปยังอินพุต pdf หรือ urloutput_dir (STR): เส้นทางไดเรกทอรีเอาต์พุตprompt (str): แจ้งให้ส่งไปยังแบบจำลองพร้อมกับรูปภาพllm_client (รายการ): รายการที่มีรุ่นขั้นต่ำหนึ่งรุ่นจากไคลเอนต์ LLMวิเคราะห์การอ้างอิงรูปภาพประเภทต่างๆใน PDF จากไฟล์ท้องถิ่นหรือ URL
พารามิเตอร์:
source (STR): เส้นทาง PDF ท้องถิ่นหรือ URL ไปยัง PDFoutput_dir (str): ไดเรกทอรีสำหรับไฟล์ชั่วคราวverbose (บูล): พิมพ์ข้อมูลรายละเอียด เรายินดีต้อนรับผลงาน! โปรดดูแนวทางการสนับสนุนของเราสำหรับรายละเอียด
git clone https://github.com/shoryasethia/markdrop.git
cd markdrop python -m venv venv
source venv/bin/activate # On Windows: venvScriptsactivate pip install -r requirements.txt markdrop/
├── LICENSE
├── README.md
├── CONTRIBUTING.md
├── CHANGELOG.md
├── requirements.txt
├── setup.py
└── markdrop/
├── models/
| ├── .env
| ├── img_descriptions.py
| ├── logger.py
| ├── model_loader.py
| ├── responder.py
| └── setup_keys.py
├── __init__.py
├── main.py
├── utils.py
├── helper.py
└── ignore_warnings.py โครงการนี้ได้รับใบอนุญาตภายใต้ใบอนุญาต MIT - ดูไฟล์ใบอนุญาตสำหรับรายละเอียด
ดู Changelog.md สำหรับประวัติเวอร์ชัน
โปรดทราบว่าโครงการนี้เป็นไปตามจรรยาบรรณของเรา