I am trying to use my custom dataset and hence downloaded the the code data_loading_tutorial available in the Pytorch tutorials.
The code works fine till the line:
transformed_dataset = FaceLandmarksDataset(csv_file=‘faces/face_landmarks.csv’,
I skipped the part of manual iteration after that using the for loop and tried to run the rest of the code from
dataloader = DataLoader(transformed_dataset, batch_size=4,
It shows the error : BrokenPipeError: [Errno 32] Broken pipe
To point out more precisely ,I would like to inform that the dataloader object is created. The error is basically created from enumerate(dataloader)
I cannot understand what might be the reason of this. Please suggest a way around this . Thanks !
Are you using Windows for this code?
If so, you should protect your code with
Otherwise Windows might try to create processes recursively, yielding your error.
Let me know, if this is the case.
Yes I am using Windows 10.
Can you please tell me where I should include the two lines ?
You could add this line at the bottom of your code, if you wrap the other code into the
Alternatively, you could wrap your whole code into the if-statement.
The important point is, that your main code should be executed inside this if-statement.
Otherwise Windows will execute the whole script, which will create processes recursively.
model = ...
for batch_idx, (data, target) in enumerate(loader):
Its working , but a new issue is that the images which where supposed to be shown , are not being shown
In fact, I suspect that the part in the if block is not being run at all.
How are you visualizing the images?
This is the code:
"""Show image with landmarks for a batch of samples."""
images_batch, landmarks_batch = \
batch_size = len(images_batch)
im_size = images_batch.size(2)
grid = utils.make_grid(images_batch)
plt.imshow(grid.numpy().transpose((1, 2, 0)))
for i in range(batch_size):
plt.scatter(landmarks_batch[i, :, 0].numpy() + i * im_size,
landmarks_batch[i, :, 1].numpy(),
s=10, marker='.', c='r')
plt.title('Batch from dataloader')
for i_batch, sample_batched in enumerate(dataloader):
# observe 4th batch and stop
if i_batch == 3:
Basically it shows a batch of 4 images using matplotlib with the help of the function
Its a part of the code in Pytorch tutorials in the Pytorch website.
I did this, but nothing shows up…