حزمة Python لتحويل PDFs (أو عناوين URL PDF) إلى تخفيض المعدل أثناء استخراج الصور والجداول. يجعل 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 إلى تنسيق تخفيض.
حدود:
source (STR): مسار لإدخال PDF أو URLoutput_dir (Str): مسار دليل الإخراجverbose (Bool): تمكين تسجيل تفصيلييستخلص الصور من PDF أو عنوان URL الخاص به مع الحفاظ على الجودة.
حدود:
source (STR): مسار لإدخال PDF أو URLoutput_dir (Str): مسار دليل الإخراجverbose (Bool): تمكين تسجيل تفصيلييكتشف ويستخلص صور الجداول.
حدود:
pdf_path (STR): مسار إلى إدخال PDF أو URLstart_page (int ، اختياري): رقم الصفحة بدءend_page (int ، اختياري): رقم الصفحة إنهاء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 تم ترخيص هذا المشروع بموجب ترخيص معهد ماساتشوستس للتكنولوجيا - راجع ملف الترخيص للحصول على التفاصيل.
انظر changelog.md للحصول على تاريخ الإصدار.
يرجى ملاحظة أن هذا المشروع يتبع مدونة قواعد سلوكنا.