Comments (3)
Why is this memory consuming?
Normally, in PyTorch, dataloaders are Python generators, meaning they will only consume RAM when iterating over them.
from transformers-tutorials.
Why is this memory consuming?
Normally, in PyTorch, dataloaders are Python generators, meaning they will only consume RAM when iterating over them.
Yeah @NielsRogge , I thought so, and I tried that but it caused the below error.
ValueError: Images must of type `PIL.Image.Image`, `np.ndarray` or `torch.Tensor` (single example),`List[PIL.Image.Image]`, `List[np.ndarray]` or `List[torch.Tensor]` (batch of examples), but is of type <class 'generator'>
The processor()
below expects Images as a List[PIL.Image.Image]
.I am new to all this. Could you help me here?
Below is the code.
class LMDataset(torch.utils.data.Dataset):
def __init__(self, encodings):
self.encodings = encodings
def __getitem__(self, idx):
item = {key: torch.tensor(val[idx]) for key, val in self.encodings.items()}
return item
def __len__(self):
return len(self.encodings)
processor = LayoutLMv2Processor.from_pretrained("microsoft/layoutlmv2-base-uncased", revision="no_ocr")
train_encodings = processor(
[Image.open(image).convert('RGB') for image in tqdm(train_df['image'])], # <--- this is causing memory issues.
train_df['words'].tolist(),
boxes=train_df['boxes'].tolist(),
word_labels=[[label2id[label] for label in labels] for labels in train_df['labels'].tolist()],
return_tensors="pt", padding='max_length', truncation=True)
train_dataset = LMDataset(train_encodings)
from transformers-tutorials.
Yes my mistake. Missed the 'yield'. Fixed that and working now.
from transformers-tutorials.
Related Issues (20)
- module 'torch' has no attribute 'torch.bfloat16' HOT 1
- SFT_of_an_LLM_using_Hugging_Face_tooling.ipynb problem with latest TRL 0.7.10 HOT 2
- Token label matching in layoutlmv3 inference
- TrOCR for Persian
- Fine Tune Layoutlmv3 on DocVQA?
- Visualizing SAM Mask decoder
- paddleocr in tabletransformer error
- Fine Tuning OneFormer for Semantic Segmentation, how to change model's class number HOT 2
- LayoutLMv3 - discard tokens with same meaning from inference
- LayoutLMv3 - Speed up the inference for more than 512 tokens
- SFT Mistral multiple gpu failure
- Adding Background Class to Training as label
- Layoutlmv3 issue with inferencing bounding box is not plotting correctly
- DINOv2 - Segmentation HOT 1
- UDOP for Information Extraction. HOT 2
- LayoutLM training after following the tutorial gives different results HOT 1
- UDOP Demo notebooks HOT 2
- UDOP different models HOT 2
- Donut fine tuning using Huggingface accelerate
- UDOP Document Generation & Editing HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from transformers-tutorials.