Real-ESRGAN icon indicating copy to clipboard operation
Real-ESRGAN copied to clipboard

【求助】AttributeError: 'NoneType' object has no attribute 'shape'

Open Jasonandy opened this issue 2 years ago • 3 comments

demo 跑不起来 image

Jasonandy avatar Jan 31 '23 03:01 Jasonandy

If the script has trouble reading your input file or directory, img will end up being NoneType hence your error message. Most likely the issue has to do with problem on your input file, or the path/filename is incorrect.

lanzer avatar Feb 15 '23 09:02 lanzer

same problem

brandy2015 avatar Mar 04 '23 01:03 brandy2015

I tried to read inputs path, this script will use glob and include all files and folder as inputs/video. The problem is if you are attempt to read the folder path, the OpenCV will return None. The next code is intended to get shape property from numpy array but it is None, so Python will raise an error.

I use os.path.isfile() to check the path is file or not, by using as list comprehension to get only file paths.

paths = [path for path in paths if os.path.isfile(path)]

I see another error when using Half-precision with CPU, the slow_conv2d_cpu is not implemented to use half-precision, you must edit the code to use FP32 instead.

    # restorer
    upsampler = RealESRGANer(
        scale=netscale,
        model_path=model_path,
        dni_weight=dni_weight,
        model=model,
        tile=args.tile,
        tile_pad=args.tile_pad,
        pre_pad=args.pre_pad,
        half=False, # Not using half-precision
        gpu_id=args.gpu_id)

paweenwat-man avatar Apr 18 '23 06:04 paweenwat-man