DECIMER-Image-Segmentation icon indicating copy to clipboard operation
DECIMER-Image-Segmentation copied to clipboard

AttributeError: 'NoneType' object has no attribute 'dtype'

Open pythonnewbie3 opened this issue 2 years ago • 3 comments

Hello, when I run the code I get this error:

AttributeError: 'NoneType' object has no attribute 'dtype'

What can I do?

pythonnewbie3 avatar Nov 11 '22 18:11 pythonnewbie3

Hi @pythonnewbie3 Could you add steps to reproduce the error?

Kohulan avatar Nov 14 '22 08:11 Kohulan

Hi @Kohulan The code is:

from decimer_segmentation import segment_chemical_structures, segment_chemical_structures_from_file
import cv2
scanned_page_file_path=r"C:/Users/Username/Desktop/test.pdf"
page = cv2.imread(scanned_page_file_path)
segments = segment_chemical_structures(page, expand=True)
segments = segment_chemical_structures_from_file(path, expand=True, poppler_path=r"C:\Program Files (x86)\poppler-0.68.0\bin")

And the error is:

Traceback (most recent call last):
  File "C:\Users\Username\Anaconda3\lib\site-packages\DECIMER\untitled0.py", line 6, in <module>
    segments = segment_chemical_structures(page, expand=True)

  File "C:\Users\Username\Anaconda3\lib\site-packages\decimer_segmentation\decimer_segmentation.py", line 100, in segment_chemical_structures
    masks = get_expanded_masks(image)

  File "C:\Users\Username\Anaconda3\lib\site-packages\decimer_segmentation\decimer_segmentation.py", line 155, in get_expanded_masks
    masks, _, _ = get_mrcnn_results(image)

  File "C:\Users\Username\Anaconda3\lib\site-packages\decimer_segmentation\decimer_segmentation.py", line 179, in get_mrcnn_results
    results = model.detect([image], verbose=1)

  File "C:\Users\Username\Anaconda3\lib\site-packages\decimer_segmentation\mrcnn\model.py", line 2849, in detect
    molded_images, image_metas, windows = self.mold_inputs(images)

  File "C:\Users\Username\Anaconda3\lib\site-packages\decimer_segmentation\mrcnn\model.py", line 2730, in mold_inputs
    molded_image, window, scale, padding, crop = utils.resize_image(

  File "C:\Users\Username\Anaconda3\lib\site-packages\decimer_segmentation\mrcnn\utils.py", line 417, in resize_image
    image_dtype = image.dtype

AttributeError: 'NoneType' object has no attribute 'dtype'

Thank you.

pythonnewbie3 avatar Nov 14 '22 11:11 pythonnewbie3

I just got a new error after changing absolutley nothing:

RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd

RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd

ImportError: numpy.core._multiarray_umath failed to import

ImportError: numpy.core.umath failed to import


Traceback (most recent call last):

  File "C:\Users\sw5222\Anaconda3\lib\site-packages\DECIMER\untitled0.py", line 1, in <module>
    from decimer_segmentation import segment_chemical_structures, segment_chemical_structures_from_file

  File "C:\Users\sw5222\Anaconda3\lib\site-packages\decimer_segmentation\__init__.py", line 19, in <module>
    from .decimer_segmentation import *

  File "C:\Users\sw5222\Anaconda3\lib\site-packages\decimer_segmentation\decimer_segmentation.py", line 20, in <module>
    from .mrcnn import model as modellib

  File "C:\Users\sw5222\Anaconda3\lib\site-packages\decimer_segmentation\mrcnn\model.py", line 20, in <module>
    import tensorflow as tf

  File "C:\Users\sw5222\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 37, in <module>
    from tensorflow.python.tools import module_util as _module_util

  File "C:\Users\sw5222\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 42, in <module>
    from tensorflow.python import data

  File "C:\Users\sw5222\Anaconda3\lib\site-packages\tensorflow\python\data\__init__.py", line 21, in <module>
    from tensorflow.python.data import experimental

  File "C:\Users\sw5222\Anaconda3\lib\site-packages\tensorflow\python\data\experimental\__init__.py", line 96, in <module>
    from tensorflow.python.data.experimental import service

  File "C:\Users\sw5222\Anaconda3\lib\site-packages\tensorflow\python\data\experimental\service\__init__.py", line 419, in <module>
    from tensorflow.python.data.experimental.ops.data_service_ops import distribute

  File "C:\Users\sw5222\Anaconda3\lib\site-packages\tensorflow\python\data\experimental\ops\data_service_ops.py", line 24, in <module>
    from tensorflow.python.data.experimental.ops import compression_ops

  File "C:\Users\sw5222\Anaconda3\lib\site-packages\tensorflow\python\data\experimental\ops\compression_ops.py", line 16, in <module>
    from tensorflow.python.data.util import structure

  File "C:\Users\sw5222\Anaconda3\lib\site-packages\tensorflow\python\data\util\structure.py", line 23, in <module>
    from tensorflow.python.data.util import nest

  File "C:\Users\sw5222\Anaconda3\lib\site-packages\tensorflow\python\data\util\nest.py", line 36, in <module>
    from tensorflow.python.framework import sparse_tensor as _sparse_tensor

  File "C:\Users\sw5222\Anaconda3\lib\site-packages\tensorflow\python\framework\sparse_tensor.py", line 24, in <module>
    from tensorflow.python.framework import constant_op

  File "C:\Users\sw5222\Anaconda3\lib\site-packages\tensorflow\python\framework\constant_op.py", line 25, in <module>
    from tensorflow.python.eager import execute

  File "C:\Users\sw5222\Anaconda3\lib\site-packages\tensorflow\python\eager\execute.py", line 23, in <module>
    from tensorflow.python.framework import dtypes

  File "C:\Users\sw5222\Anaconda3\lib\site-packages\tensorflow\python\framework\dtypes.py", line 34, in <module>
    _np_bfloat16 = _pywrap_bfloat16.TF_bfloat16_type()

TypeError: Unable to convert function return value to a Python type! The signature was
	() -> handle

pythonnewbie3 avatar Nov 14 '22 13:11 pythonnewbie3