|
| | __init__ (self, pd.DataFrame dataframe, str bucket_name, Optional[callable] image_transform=None, Optional[PreTrainedTokenizerBase] tokenizer=None, int max_sentences=15, int max_sent_length=50, Optional[dict] vocab=None, str ocr_lang='eng', str minio_endpoint="localhost:9900", str minio_access_key="minioadmin", str minio_secret_key="minioadmin", bool minio_secure=False, bool batch_tokenize=False, Optional[dict] label_map=None) |
| | Constructor for MinioMultiModalDataset class.
|
| |
| | client (self) |
| | Property to get MinIO client, initializing if needed.
|
| |
| | __len__ (self) |
| | Returns the number of items in the dataset.
|
| |
| | __getitem__ (self, idx) |
| | Fetches and processes a single item from the dataset.
|
| |
PyTorch Dataset for loading images and extracting text via OCR from MinIO.
This class extends PyTorch's Dataset class to load images from MinIO object storage and utilize pre-computed OCR results from the dataframe.
PyTorch Dataset for loading images and pre-computed OCR text from MinIO.
| classification.data.minio_dataset.MinioMultiModalDataset.__init__ |
( |
|
self, |
|
|
pd.DataFrame |
dataframe, |
|
|
str |
bucket_name, |
|
|
Optional[callable] |
image_transform = None, |
|
|
Optional[PreTrainedTokenizerBase] |
tokenizer = None, |
|
|
int |
max_sentences = 15, |
|
|
int |
max_sent_length = 50, |
|
|
Optional[dict] |
vocab = None, |
|
|
str |
ocr_lang = 'eng', |
|
|
str |
minio_endpoint = "localhost:9900", |
|
|
str |
minio_access_key = "minioadmin", |
|
|
str |
minio_secret_key = "minioadmin", |
|
|
bool |
minio_secure = False, |
|
|
bool |
batch_tokenize = False, |
|
|
Optional[dict] |
label_map = None |
|
) |
| |
Constructor for MinioMultiModalDataset class.
- Parameters
-
| dataframe | DataFrame with 'image' URL, 'label', and OCR columns ('ocr_text', 'ocr_confidence', 'ocr_boxes') |
| bucket_name | MinIO bucket name |
| image_transform | Transformations for the image |
| tokenizer | Tokenizer instance to process text |
| max_sentences | Maximum number of sentences to keep from OCR text |
| max_sent_length | Maximum number of tokens per sentence |
| vocab | Vocabulary mapping tokens to indices |
| ocr_lang | Tesseract language code(s) for fallback OCR if needed |
| minio_endpoint | MinIO server endpoint URL |
| minio_access_key | MinIO access key |
| minio_secret_key | MinIO secret key |
| minio_secure | Use TLS for MinIO connection |
| batch_tokenize | Whether to tokenize in batches (more efficient) |
| label_map | Optional dictionary mapping label strings to integers |
Args:
dataframe: DataFrame with 'image' URL, 'label', and OCR columns.
bucket_name: MinIO bucket name.
image_transform: Transformations for the image.
tokenizer: Tokenizer instance (e.g., from Hugging Face) to process text.
max_sentences: Maximum number of sentences to keep from OCR text.
max_sent_length: Maximum number of tokens per sentence.
vocab: Vocabulary mapping tokens to indices (if tokenizer doesn't handle it).
ocr_lang: Tesseract language code(s) for fallback OCR if needed.
minio_endpoint: MinIO server endpoint URL.
minio_access_key: MinIO access key.
minio_secret_key: MinIO secret key.
minio_secure: Use TLS for MinIO connection.
batch_tokenize: Whether to tokenize in batches (more efficient).
label_map: Optional dictionary mapping label strings to integers.