Pytorch-yolov3: AttributeError: 'str' object has no attribute 'seek'

Created on 22 May 2019  Â·  10Comments  Â·  Source: eriklindernoren/PyTorch-YOLOv3

when I run train.py.here are custom dataset:

images:
datacustomimages1.jpg
datacustomimages2.jpg
..
labels:
datacustomlabels1.txt (format like this e.g. 3 0.475938 0.377917 0.144375 0.189167)
datacustomlabels2.txt
..

return the error message:

File "train.py", line 164, in
batch_size=8,
File "D:workspacePyTorch-YOLOv3test.py", line 36, in evaluate
for batch_i, (_, imgs, targets) in enumerate(tqdm.tqdm(dataloader, desc="Detecting objects")):
File "C:UsersuserAnaconda3envstf1.13libsite-packagestqdm_tqdm.py", line 1022, in __iter__
for obj in iterable:
File "C:UsersuserAnaconda3envstf1.13libsite-packagestorchutilsdatadataloader.py", line 637, in __next__
return self._process_next_batch(batch)
File "C:UsersuserAnaconda3envstf1.13libsite-packagestorchutilsdatadataloader.py", line 658, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
AttributeError: Traceback (most recent call last):
File "C:UsersuserAnaconda3envstf1.13libsite-packagesPILImage.py", line 2638, in open
fp.seek(0)
AttributeError: 'str' object has no attribute 'seek'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:UsersuserAnaconda3envstf1.13libsite-packagestorchutilsdatadataloader.py", line 138, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "C:UsersuserAnaconda3envstf1.13libsite-packagestorchutilsdatadataloader.py", line 138, in
samples = collate_fn([dataset[i] for i in batch_indices])
File "D:workspacePyTorch-YOLOv3utilsdatasets.py", line 86, in __getitem__
img = transforms.ToTensor()(Image.open(img_path).convert('RGB'))
File "C:UsersuserAnaconda3envstf1.13libsite-packagesPILImage.py", line 2640, in open
fp = io.BytesIO(fp.read())
AttributeError: 'str' object has no attribute 'read'

Most helpful comment

@yyx1107
You can check your data/custom/train. txt and valid.txt carefully to see if there are any empty lines at the end, and if so, delete them.

All 10 comments

Have you resovled the problem?

@yyx1107
You can check your data/custom/train. txt and valid.txt carefully to see if there are any empty lines at the end, and if so, delete them.

@yyx1107
You can check your data/custom/train. txt and valid.txt carefully to see if there are any empty lines at the end, and if so, delete them.

in addition, if you have any empty lines at all in the two files stated above delete them

what do you mean by deleting them?

like erase them

Hey, what do i need to erase?

чт, 11 февр. 2021 г., 23:41 SarahOye notifications@github.com:

like erase them

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/eriklindernoren/PyTorch-YOLOv3/issues/183#issuecomment-777810502,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ARWHXDVXO2WFNH7I2P6CTYDS6RFIRANCNFSM4HOQB5IQ
.

Just deleting them

пт, 12 февр. 2021 г., 7:17 SarahOye notifications@github.com:

any empty lines

On Fri, Feb 12, 2021 at 12:12 AM Zachary (Zecharia) Fenton <
[email protected]> wrote:

Hey, what do i need to erase?

чт, 11 февр. 2021 г., 23:41 SarahOye notifications@github.com:

like erase them

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<

https://github.com/eriklindernoren/PyTorch-YOLOv3/issues/183#issuecomment-777810502

,
or unsubscribe
<

https://github.com/notifications/unsubscribe-auth/ARWHXDVXO2WFNH7I2P6CTYDS6RFIRANCNFSM4HOQB5IQ
>

.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_eriklindernoren_PyTorch-2DYOLOv3_issues_183-23issuecomment-2D777976582&d=DwMFaQ&c=0CCt47_3RbNABITTvFzZbA&r=wz0tmQjFq4GeobrncM7ujwzwMQqc6nKRrTDyjxS3BAI&m=yrA0G79R6VBGioOh0raE2XMPQDRybuRGM4g1oMgv4zk&s=h62MeANFCzER9V650wJdO1mn_M3O35X--cJ3El95Lx8&e=
,
or unsubscribe
<
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ARWBVSFJIZ5AXLMF54RDBRDS6S2CJANCNFSM4HOQB5IQ&d=DwMFaQ&c=0CCt47_3RbNABITTvFzZbA&r=wz0tmQjFq4GeobrncM7ujwzwMQqc6nKRrTDyjxS3BAI&m=yrA0G79R6VBGioOh0raE2XMPQDRybuRGM4g1oMgv4zk&s=9kx4c7RjwZjiGF5vNrJ6qnwOYUHWvFtkcVbSzI-BNQQ&e=

.

--
Best,
Sarah Oyekoya

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/eriklindernoren/PyTorch-YOLOv3/issues/183#issuecomment-777978783,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ARWHXDRBTGF2PSU2TYLDN3LS6S2V3ANCNFSM4HOQB5IQ
.

yes exactly

Thanks ill try that

пт, 12 февр. 2021 г., 8:10 SarahOye notifications@github.com:

yes exactly

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/eriklindernoren/PyTorch-YOLOv3/issues/183#issuecomment-777998489,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ARWHXDXEZTB3UDUJZ7TK2MLS6TA5HANCNFSM4HOQB5IQ
.

Was this page helpful?
0 / 5 - 0 ratings