New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ValueError: Caught ValueError in DataLoader worker process 0. #365
Comments
i am using this project for resume parser having 15k images. when using voc format and training i get this error in lr.finder |
Also without doing any processing and augmentation on images i get this error |
@arhamzamindar Also, please share the entire stack trace and your system details. We can debug it further 👍 |
yes i am running on cpu. i tried using num_workers =0 it trained for some time and then i got this error i am using this code to create Resume parser WARNING: Make sure you have already cloned the raccoon dataset using the command shown here aboveSet images and annotations directoriesdata_dir = Path('/home/arham/object-detection-for-resume-using-mantisshrimp/data') Define class_mapclass_map = ClassMap(["education","work experience","projects","achievements","certificates","background"]) Parser: Use mantisshrimp predefined VOC parserparser = parsers.voc( train and validation recordsdata_splitter = RandomSplitter([0.8, 0.2]) show_records(train_records[:3], ntrain_ds = Dataset(train_records, train_tfms) train_dl = efficientdet.train_dl(train_ds, batch_size=16, num_workers=0, shuffle=True) model = efficientdet.model('tf_efficientdet_lite0', num_classes=len(class_map), img_size=size) metrics = [COCOMetric(metric_type=COCOMetricType.bbox)] learn = efficientdet.fastai.learner(dls=[train_dl, valid_dl], model=model, metrics=metrics) My system details. Please help my further with my problem |
Your dataset labels should be (xmin, ymin, xmax, ymax)
which isn't so. it's xmax, ymax, xmin, ymin. I guess you need to re-order in the parser. Also, you should probably use GPU, and check if it is getting used. It would take lot of time on CPU. |
I am using VOC format in this notebook but i have the csv file and it has correct form like xmin ymin xmax ymax. i think the annotation done is not in the correct form . maybe i'll have to remove the images where there is such problem
|
@oke-aditya |
I face similar issue using kaggle GPU. After the 1st epoch the process dies. I tried using def train_dataloader(self):
faster_rcnn.train_dl(self.trainset, batch_size=self.batch_size, num_workers=0, shuffle=True) I use |
@lgvaz @ai-fast-track . This might need a fix. |
@tugot17 what was the error that pops up when you use |
@arhamzamindar that error is a simple assertion to make sure the bbox is valid, if you're still getting that error it means that there is still a single sample were the values are incorrect. Could you post the full error you got in the last run? Also, when posting code, don't forget to surround it with ``` for highlight |
@lgvaz yes so this is the error i get when doing lr.fi
|
The error is very clear @arhamzamindar, and notice that it's being thrown by albumentations, x_max is 0.56 and x_min is 0.098. Your data is either invalid or your misunderstanding it's format. |
@lgvaz i am adding other errors i encountered on the same code This i received after i tried removing files where minimum was greater than large for both x any y. Also can you guide me how to change my data(probably XML'S) so i can run use mantis shrimp coz this is best to do object detection and I don't want to opt for some other library. |
It have the impression that your dataset might be in the |
High chance, Efficient det takes |
@oke-aditya it does not depend on the model though, the library internally figures out the right format to pass to the models, what I think is wrong is his parser. If I understood correctly he's using the VOC parser, which expects bboxes to be in xyxy, but maybe his dataset is xywh? |
YES,this may be a possibility because we did annotation on dataturks that provides output in json format which had 8 co-ordinates. My colleague took the 1st 4th 5th and 6th co-ordinates coz bbox was drawn with that co-ordinates. We also tried training on Fastai but that rejected most of our images and only ran on a few of them(reason for that is not known). I am trying to edit the XML files and sort out the issue. |
Keep in mind that if that is the case, you don't need to edit your data, but only to subclass You would probably change something here (parsers->voc_parser.py): def bboxes(self, o) -> List[BBox]:
def to_int(x):
return int(float(x))
bboxes = []
for object in self._root.iter("object"):
xml_bbox = object.find("bndbox")
xmin = to_int(xml_bbox.find("xmin").text)
ymin = to_int(xml_bbox.find("ymin").text)
xmax = to_int(xml_bbox.find("xmax").text)
ymax = to_int(xml_bbox.find("ymax").text)
bbox = BBox.from_xyxy(xmin, ymin, xmax, ymax)
bboxes.append(bbox)
return bboxes |
@lgvaz i changed my xml file but now in the data_splitter i get this error.
|
I am a newbee and maybe this is a noob query.I read the thread and checked my xmin, ymin, xmax , x max, y max used BBox.fromxywh there boxes doesnt fit the image object whereas when i use BBox.fromxyxy in show_samples i can see the bounding boxes perfectly fit the image objects as well. When i am using lr_find it threw me an error the first time i ran it (error pasted below). I ran the code again without changing anything lr_find was running but then fine_tune threw the same error. Attached the code.( I am running the whole thing on colab) Dataset:- https://github.com/gulvarol/grocerydataset ---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-25-c232684d32d4> in <module>()
1 learn.freeze()
----> 2 learn.lr_find()
9 frames
/usr/local/lib/python3.6/dist-packages/torch/_utils.py in reraise(self)
393 # (https://bugs.python.org/issue2651), so we work around it.
394 msg = KeyErrorMessage(msg)
--> 395 raise self.exc_type(msg)
ValueError: Caught ValueError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/worker.py", line 185, in _worker_loop
data = fetcher.fetch(index)
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py", line 34, in fetch
data = next(self.dataset_iter)
File "/usr/local/lib/python3.6/dist-packages/fastai2/data/load.py", line 107, in create_batches
yield from map(self.do_batch, self.chunkify(res))
File "/usr/local/lib/python3.6/dist-packages/fastcore/utils.py", line 299, in chunked
res = list(itertools.islice(it, chunk_sz))
File "/usr/local/lib/python3.6/dist-packages/fastai2/data/load.py", line 120, in do_item
try: return self.after_item(self.create_item(s))
File "/usr/local/lib/python3.6/dist-packages/fastai2/data/load.py", line 126, in create_item
def create_item(self, s): return next(self.it) if s is None else self.dataset[s]
File "/usr/local/lib/python3.6/dist-packages/icevision/data/dataset.py", line 38, in __getitem__
data = self.tfm(data)
File "/usr/local/lib/python3.6/dist-packages/icevision/tfms/transform.py", line 13, in __call__
tfmed = self.apply(**data)
File "/usr/local/lib/python3.6/dist-packages/icevision/tfms/albumentations/tfms.py", line 110, in apply
d = self.tfms(**params)
File "/usr/local/lib/python3.6/dist-packages/albumentations/core/composition.py", line 174, in __call__
p.preprocess(data)
File "/usr/local/lib/python3.6/dist-packages/albumentations/core/utils.py", line 62, in preprocess
data[data_name] = self.check_and_convert(data[data_name], rows, cols, direction="to")
File "/usr/local/lib/python3.6/dist-packages/albumentations/core/utils.py", line 70, in check_and_convert
return self.convert_to_albumentations(data, rows, cols)
File "/usr/local/lib/python3.6/dist-packages/albumentations/augmentations/bbox_utils.py", line 51, in convert_to_albumentations
return convert_bboxes_to_albumentations(data, self.params.format, rows, cols, check_validity=True)
File "/usr/local/lib/python3.6/dist-packages/albumentations/augmentations/bbox_utils.py", line 303, in convert_bboxes_to_albumentations
return [convert_bbox_to_albumentations(bbox, source_format, rows, cols, check_validity) for bbox in bboxes]
File "/usr/local/lib/python3.6/dist-packages/albumentations/augmentations/bbox_utils.py", line 303, in <listcomp>
return [convert_bbox_to_albumentations(bbox, source_format, rows, cols, check_validity) for bbox in bboxes]
File "/usr/local/lib/python3.6/dist-packages/albumentations/augmentations/bbox_utils.py", line 251, in convert_bbox_to_albumentations
check_bbox(bbox)
File "/usr/local/lib/python3.6/dist-packages/albumentations/augmentations/bbox_utils.py", line 330, in check_bbox
"to be in the range [0.0, 1.0], got {value}.".format(bbox=bbox, name=name, value=value)
ValueError: Expected y_max for bbox (0.33458646616541354, 0.9720394736842105, 0.38721804511278196, 1.0674342105263157, 0) to be in the range [0.0, 1.0], got 1.0674342105263157. |
Reason of error is It expects normalized boxes. It has to be between 0 and 1.0. |
I have used normalization in transforms |
Also i have attached the entire code. Please let me know where i am going wrong |
The error is a bit cryptic because it's internally being thrown by albumentations.
To clarify the quote here above the error is not that icevision expects normalized bboxes, the normalization actually happens inside albumentations. The cause of this error is that there is at least one bbox in your dataset that has a coordinate that is bigger than the image dimensions. What you will need to do is to clip the bboxes coordinates so it stays within the image dimensions. Some steps that might help you:
Note: This is not related to the current error but, the fields |
The issue got stale so I believe it's solved, I'll be closing it |
there are some corrupt images in the grocery dataset. somewhere between image_id 8000- 8500 images in the "train folder",drop those. |
🚀 Feature
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: