Skip to content
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: need at least one array to stack #23

Closed
frothmoon opened this issue Oct 6, 2018 · 9 comments
Closed

ValueError: need at least one array to stack #23

frothmoon opened this issue Oct 6, 2018 · 9 comments

Comments

@frothmoon
Copy link

frothmoon commented Oct 6, 2018

I have encountered a problem and really need your help. Can you help me?
I want to train my own coco dataset. When I run train.py, the problem occur
like this:

Traceback (most recent call last):
  File "train.py", line 193, in <module>
    main(opt)
  File "train.py", line 116, in main
    for i, (imgs, targets) in enumerate(dataloader):
  File "/home/pytorch/github/yolov3/utils/datasets.py", line 189, in __next__
    img_all = np.stack(img_all)[:, :, :, ::-1].transpose(0, 3, 1, 2)  # BGR to RGB and cv2 to pytorch
  File "/home/pytorch/anaconda3/envs/pytorch0.4/lib/python3.6/site-packages/numpy/core/shape_base.py", line 349, in stack
    raise ValueError('need at least one array to stack')
ValueError: need at least one array to stack

I change the coco.data like this:

classes= 3
train=data/coco/trainval.txt
valid=data/coco/test.txt
names=data/coco.names
backup=backup/
eval=coco

and the train_path in train.py:

if platform == 'darwin':  # MacOS (local)
        train_path = data_config['train']
    else:  # linux (cloud, i.e. gcp)
        train_path = 'data/coco/trainval.txt'

Thank you in advance!

@lookup1980
Copy link

Same problem here!

@pprp
Copy link

pprp commented Feb 22, 2019

you should check coco.data and the train file in coco.data. I solved the problem by changing coco.data

@glenn-jocher
Copy link
Member

glenn-jocher commented Feb 22, 2019

@lookup1980 you are receiving this error because the dataloader is not finding any images to load in the path you provided. If you are trying to train on a custom dataset follow these directions:
https://github.com/ultralytics/yolov3/wiki/Example:-Train-Single-Class

@lookup1980
Copy link

Thank you @pprp and @glenn-jocher !

@kaaier
Copy link

kaaier commented Mar 5, 2019

您好,我出现和您同样的错误,请问如何解决?.data中的路径信息是正确的绝对路径。

@kaaier
Copy link

kaaier commented Mar 5, 2019

Hello, I have the same mistake as you. How can I solve it? The path information in.data is the correct absolute path.

@pprp
Copy link

pprp commented Mar 5, 2019

@NinikFL
Copy link

NinikFL commented Jun 7, 2024

Hii, i hve also same problem to convert Dicom file into .npy file. could somebody help me plase?

@glenn-jocher
Copy link
Member

Hello! It seems like you're facing an issue with converting DICOM files to .npy format. This task is a bit outside the typical usage of YOLOv3, which primarily deals with image detection tasks. However, you can use libraries like pydicom to read DICOM files and numpy to save them as .npy files. Here’s a quick example:

import pydicom
import numpy as np

# Load your DICOM file
dicom = pydicom.dcmread('path_to_dicom_file.dcm')

# Convert to numpy array
array = dicom.pixel_array

# Save to .npy file
np.save('output_file.npy', array)

This should help you convert your DICOM files into the format you need. If you have further questions regarding YOLOv3 specifically, feel free to ask!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants