yenchenlin / nerf-pytorch

A PyTorch implementation of NeRF (Neural Radiance Fields) that reproduces the results.
MIT License
5.33k stars 1.04k forks source link

TypeError: read() got an unexpected keyword argument 'ignoregamma' (Solution Provided) #140

Open JY251 opened 1 month ago

JY251 commented 1 month ago

I have encountered the following error. I have found a solution so I will share with you.

python run_nerf.py --config configs/fern.txt
Traceback (most recent call last):
  File "run_nerf.py", line 878, in <module>
    train()
  File "run_nerf.py", line 542, in train
    images, poses, bds, render_poses, i_test = load_llff_data(args.datadir, args.factor,
  File "/nerf-pytorch/load_llff.py", line 246, in load_llff_data
    poses, bds, imgs = _load_data(basedir, factor=factor) # factor=8 downsamples original imgs by 8x
  File "/nerf-pytorch/load_llff.py", line 114, in _load_data
    imgs = imgs = [imread(f)[...,:3]/255. for f in imgfiles]
  File "/nerf-pytorch/load_llff.py", line 114, in <listcomp>
    imgs = imgs = [imread(f)[...,:3]/255. for f in imgfiles]
  File "/nerf-pytorch/load_llff.py", line 110, in imread
    return imageio.imread(f, ignoregamma=True)
  File "/usr/local/lib/python3.8/dist-packages/imageio/__init__.py", line 97, in imread
    return imread_v2(uri, format=format, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/imageio/v2.py", line 360, in imread
    result = file.read(index=0, **kwargs)
TypeError: read() got an unexpected keyword argument 'ignoregamma'

This issue is similar to Issue #190 in the original bmild/nerf repository, which is implemented based on Tensorflow (but not PyTorch). Similar with this, to resolve it, update line 110 of load_llff.py as follows:

            return imageio.imread(f, apply_gamma=True)

I hope this helps!