markdrop
1.0.0
画像とテーブルを抽出しながら、PDF(またはPDF URL)をマークダウンに変換するためのPythonパッケージ。 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またはURLへのパスoutput_dir (str):出力ディレクトリパスverbose (bool):詳細なロギングを有効にします品質を維持しながら、PDFまたはそのURLから画像を抽出します。
パラメーター:
source (STR):入力PDFまたはURLへのパスoutput_dir (str):出力ディレクトリパスverbose (bool):詳細なロギングを有効にしますテーブル画像を検出して抽出します。
パラメーター:
pdf_path (STR):入力PDFまたはURLへのパスstart_page (int、optional):開始ページ番号end_page (int、optional):終了ページ番号threshold (フロート、オプション):検出信頼のしきい値output_dir (str):出力ディレクトリパスCSVで指定されたプロンプトとLLM_CLIENTに基づいて画像の説明を生成します
サポートされている
llm clientsは['qwen'、 'gemini'、 'openai'、 'llama-vision'、 'molmo'、 'pixtral']です。
パラメーター:
input_path (str):入力pdfまたはurlへのパスoutput_dir (str):出力ディレクトリパスprompt (str):画像と一緒にモデルに送信するプロンプトllm_client (リスト):LLMクライアントからの最低1つのモデルを含むリストローカルファイルまたはURLからPDFでさまざまなタイプの画像参照を分析する
パラメーター:
source (STR):ローカルPDFパスまたはPDFへのURLoutput_dir (str):一時ファイルのディレクトリverbose (bool):詳細情報を印刷します貢献を歓迎します!詳細については、貢献ガイドラインをご覧ください。
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を参照してください。
このプロジェクトは私たちの行動規範に従っていることに注意してください。