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
assert len(indices) == len(self) #62
Comments
Could you post the full log here? |
thanks,
sys.platform: linux
TorchVision: 0.7.0
|
I am not sure what the problem is. I have tried to change the |
thanks a lot!!! |
Could you have a look at the json file and check whether correct number of instances is loaded? I have tried to build a similar python environment and similar config but it seems ok. |
I guess the parametyer epoch_length is too small for your dataset since I encountered the same problem in my medical daataset weeks ago and solved this simply by turning it bigger. I haven't carefully look at the sampler code so it's just a simple and maybe unreasonable guess. |
I am having this same issue. Regardless of what I set epoch_length to, _base_ = [parent_dir+'SoftTeacher/configs/soft_teacher/base.py']
data = dict(
samples_per_gpu=2,
workers_per_gpu=2,
train = dict(
sup = dict(
ann_file=parent_dir+sup_data_path+'/train_data/annotations.json',
img_prefix=parent_dir+sup_data_path+'/train_data/',
classes=classes
),
unsup = dict(
ann_file=parent_dir+unsup_data_path+'/train_data/annotations.json',
img_prefix=parent_dir+unsup_data_path+'/train_data/',
classes=classes
),
),
val = dict(
ann_file=parent_dir+sup_data_path+'/val_data/annotations.json',
img_prefix=parent_dir+sup_data_path+'/val_data/',
classes=classes
),
test = dict(
ann_file=parent_dir+sup_data_path+'/val_data/annotations.json',
img_prefix=parent_dir+sup_data_path+'/val_data/',
classes=classes
),
sampler=dict(
train=dict(
type="SemiBalanceSampler",
sample_ratio=[1, 4],
by_prob=True,
# at_least_one=True,
epoch_length=1000,
)
),
)
evaluation = dict(interval=1000, metric='bbox', type='SubModulesDistEvalHook')
optimizer = dict(type='SGD', lr=0.001, momentum=0.9, weight_decay=0.0001)
optimizer_config = dict(grad_clip=None)
evaluation = dict(type="SubModulesDistEvalHook", interval=4000)
optimizer = dict(type="SGD", lr=0.01, momentum=0.9, weight_decay=0.0001)
lr_config = dict(step=[3000, 4000])
runner = dict(_delete_=True, type="IterBasedRunner", max_iters=5000)
checkpoint_config = dict(by_epoch=False, interval=1000, max_keep_ckpts=2)
fp16 = dict(loss_scale="dynamic")
log_config = dict(
interval=49,
hooks=[
dict(type="TextLoggerHook", by_epoch=False),
dict(
type="WandbLoggerHook",
init_kwargs=dict(
project="pre_release",
name="${cfg_name}",
config=dict(
work_dirs="${work_dir}",
total_step="${runner.max_iters}",
),
),
by_epoch=False,
),
],
) |
@jessicametzger I have same problem. Did you solve this? |
@watermellon2018 I was able to to fix it by setting |
@winnerziqi how you solved this issue? |
where did you set self.by_prob =false exactly .. in the code its a part of if loop |
i got it. in my config, it already set to False . and i still have same problem .. what shall i do ? |
how did u solve the problem? |
thank u, I'll have a try. |
hello,
When I use it, raise error: "assert len(indices) == len(self), f"{indices} not equal {len(self)} while offset is: {offset}""
then I print the length info, =====len of indices is 26865 - offset: 0 - len self 36650
below is the detail error info, Please help me.
Traceback (most recent call last): File "tools/train.py", line 198, in <module> main() File "tools/train.py", line 193, in main meta=meta, File "/data6/ziqiwen/code/softteacher/ssod/apis/train.py", line 206, in train_detector runner.run(data_loaders, cfg.workflow) File "/home/ziqiwen/anaconda3/envs/mm/lib/python3.7/site-packages/mmcv/runner/iter_based_runner.py", line 117, in run iter_loaders = [IterLoader(x) for x in data_loaders] File "/home/ziqiwen/anaconda3/envs/mm/lib/python3.7/site-packages/mmcv/runner/iter_based_runner.py", line 117, in <listcomp> iter_loaders = [IterLoader(x) for x in data_loaders] File "/home/ziqiwen/anaconda3/envs/mm/lib/python3.7/site-packages/mmcv/runner/iter_based_runner.py", line 23, in __init__ self.iter_loader = iter(self._dataloader) File "/home/ziqiwen/anaconda3/envs/mm/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 291, in __iter__ return _MultiProcessingDataLoaderIter(self) File "/home/ziqiwen/anaconda3/envs/mm/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 764, in __init__ self._try_put_index() File "/home/ziqiwen/anaconda3/envs/mm/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 994, in _try_put_index index = self._next_index() File "/home/ziqiwen/anaconda3/envs/mm/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 357, in _next_index return next(self._sampler_iter) # may raise StopIteration File "/home/ziqiwen/anaconda3/envs/mm/lib/python3.7/site-packages/torch/utils/data/sampler.py", line 208, in __iter__ for idx in self.sampler: File "/data6/ziqiwen/code/softteacher/ssod/datasets/samplers/semi_sampler.py", line 189, in __iter__ assert len(indices) == len(self) AssertionError Traceback (most recent call last): File "/home/ziqiwen/anaconda3/envs/mm/lib/python3.7/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/home/ziqiwen/anaconda3/envs/mm/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/ziqiwen/anaconda3/envs/mm/lib/python3.7/site-packages/torch/distributed/launch.py", line 261, in <module> main() File "/home/ziqiwen/anaconda3/envs/mm/lib/python3.7/site-packages/torch/distributed/launch.py", line 257, in main cmd=cmd)
The text was updated successfully, but these errors were encountered: