ComfyUI-Documents
📄 Description
ComfyUI-Documents is a powerful extension for the ComfyUI application, designed to enhance your workflow with advanced document processing capabilities. This module seamlessly integrates document handling, parsing, and conversion features directly into your ComfyUI projects.
✨ Key Features
-
Document Loader Node: Easily browse, select, and parse documents from your input directory.
- Supports multiple file formats including PDF, TXT, DOC, and DOCX.
- Extracts text content, images, and metadata from documents.
-
PDF to Image Node: Convert PDF pages into high-quality image tensors.
- Flexible page range selection for partial document processing.
- Adjustable DPI settings for output image quality control.
-
PDF Page Splitter Node: Select specific pages from a PDF document.
- Choose individual pages or ranges of pages.
- Output selected pages as separate image tensors.
-
Image Selector Node: Pick specific images from a batch of images.
- Select one or multiple images by index.
- Useful for further processing of specific pages from PDF conversions.
-
Text Chunker Node: Divide large text into manageable chunks.
- Split text by character or word count.
- Respect word boundaries for more natural text division.
-
Chunk Router Node (Currently Not Working) (WIP) : Select specific text chunks for further processing.
- Route individual chunks to different parts of your workflow.
- Useful for processing long documents in parts.
-
Intuitive File Upload: Drag-and-drop functionality for quick file imports.
-
Seamless ComfyUI Integration: Custom nodes appear directly in your ComfyUI workflow, allowing for easy incorporation into existing projects.
🛠️ Installation
- Navigate to your ComfyUI custom nodes directory:
cd ComfyUI/custom_nodes/
- Clone this repository:
git clone https://github.com/Excidos/ComfyUI-Documents.git
- Install the required dependencies (The install script should handle this automatically when you run ComfyUI):
pip install -r ComfyUI-Documents/requirements.txt
🚀 Usage
Document Loader Node
- Add the "Document Loader" node to your ComfyUI workflow.
- Use the dropdown to select a document from your input directory, or use the "Choose file to upload" button to add a new document.
- Connect the output to other nodes in your workflow to process the extracted text, images, or metadata.
![Document Loader Node](https://github.com/IndrasMirror/ComfyUI-Documents/assets/111665831/cb9c0ab8-976f-4462-856f-17731eb3e852)
PDF to Image Node
- Add the "PDF to Image" node to your ComfyUI workflow.
- Select a PDF file using the dropdown or file upload button.
- Set the desired page range and DPI.
- The node will output image tensors that can be used with other ComfyUI image processing nodes.
![PDF to Image Node](https://github.com/IndrasMirror/ComfyUI-Documents/assets/111665831/34cb7333-09c3-4086-845e-bc4ca133f9ea)
PDF Page Splitter Node
- Add the "PDF Page Splitter" node to your workflow.
- Select a PDF file using the dropdown.
- Enter the desired page numbers (e.g., "1,3,5" or "1-5,7,9-11").
- Set the DPI for the output images.
- The node will output the selected pages as separate image tensors.
![image](https://github.com/Excidos/ComfyUI-Documents/assets/173048329/5259c68c-cc5d-4b0e-8193-8c675c75df93)
Image Selector Node (WIP)
- Connect the output of a PDF to Image or PDF Page Splitter node to the Image Selector node.
- Enter the indexes of the images you want to select (e.g., "0" for the first image, or "0,2,4" for the first, third, and fifth images).
- The node will output only the selected images for further processing.
Text Chunker Node
- Connect the output of a Document Loader or any text-producing node to the Text Chunker node.
- Set the desired chunk size and method (characters or words).
- Choose whether to respect word boundaries.
- The node will output chunked text and corresponding indices.
![image](https://github.com/Excidos/ComfyUI-Documents/assets/173048329/a05cda0d-fa86-4545-97a3-855404520b95)
Chunk Router Node (Currently Not Working) (WIP)
- Connect the output of the Text Chunker node to the Chunk Router node.
- Select the index of the chunk you want to process.
- The node will output the selected chunk for further processing.
📋 Supported File Types
- PDF (.pdf)
- Plain Text (.txt)
- Microsoft Word (.doc, .docx)
🤝 Contributing
Contributions to ComfyUI-Documents are welcome! Please feel free to submit a Pull Request.
🙏 Acknowledgements
- ComfyUI for the amazing base project.
- PyMuPDF for robust PDF processing capabilities.
- python-docx for handling Microsoft Word documents.
For more information and updates, please visit the ComfyUI-Documents GitHub repository.