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

Error with single page PDF at the get_mask_center function #63

Closed
Iagea opened this issue Jan 3, 2023 · 3 comments · Fixed by #78
Closed

Error with single page PDF at the get_mask_center function #63

Iagea opened this issue Jan 3, 2023 · 3 comments · Fixed by #78
Assignees
Labels
bug Something isn't working

Comments

@Iagea
Copy link

Iagea commented Jan 3, 2023

Hi,

the following error appears with the attached PDF document, do you know why?

Best,
Isa.

Traceback (most recent call last): File "/Users/mag/UCMI/DECIMER-Image-Segmentation/segment_structures_in_document.py", line 45, in <module> main() File "/Users/mag/UCMI/DECIMER-Image-Segmentation/segment_structures_in_document.py", line 22, in main raw_segments = segment_chemical_structures_from_file(sys.argv[1]) File "/Users/mag/UCMI/DECIMER-Image-Segmentation/decimer_segmentation/decimer_segmentation.py", line 75, in segment_chemical_structures_from_file segments = segment_chemical_structures(images[0]) File "/Users/mag/UCMI/DECIMER-Image-Segmentation/decimer_segmentation/decimer_segmentation.py", line 100, in segment_chemical_structures masks = get_expanded_masks(image) File "/Users/mag/UCMI/DECIMER-Image-Segmentation/decimer_segmentation/decimer_segmentation.py", line 157, in get_expanded_masks expanded_masks = complete_structure_mask(image_array=image, mask_array=masks) File "/Users/mag/UCMI/DECIMER-Image-Segmentation/decimer_segmentation/complete_structure.py", line 451, in complete_structure_mask mask_array = np.stack(expanded_split_mask_arrays, -1) File "<__array_function__ internals>", line 180, in stack File "/Users/mag/opt/anaconda3/envs/DECIMER_IMGSEG/lib/python3.10/site-packages/numpy/core/shape_base.py", line 420, in stack arrays = [asanyarray(arr) for arr in arrays] File "/Users/mag/opt/anaconda3/envs/DECIMER_IMGSEG/lib/python3.10/site-packages/numpy/core/shape_base.py", line 420, in <listcomp> arrays = [asanyarray(arr) for arr in arrays] File "/Users/mag/UCMI/DECIMER-Image-Segmentation/decimer_segmentation/complete_structure.py", line 399, in expansion_coordination seed_pixels = get_seeds(image_array, mask_array) File "/Users/mag/UCMI/DECIMER-Image-Segmentation/decimer_segmentation/complete_structure.py", line 297, in get_seeds x_center, y_center = get_mask_center(mask_array) File "/Users/mag/UCMI/DECIMER-Image-Segmentation/decimer_segmentation/complete_structure.py", line 280, in get_mask_center x_center = np.where(mask_array[y_center] == True)[0][0] IndexError: index 0 is out of bounds for axis 0 with size 0

105.pdf

@Kohulan Kohulan added the bug Something isn't working label Mar 31, 2023
@Kohulan
Copy link
Owner

Kohulan commented Mar 31, 2023

This PDF also crashes decimer.ai

@OBrink
Copy link
Collaborator

OBrink commented Sep 18, 2023

Oh wow, sorry, I somehow forgot about this issue existing. I am on it now and will send a PR soon.

The problem seems to be that an empty mask is returned by the model and there are no seed pixels to be determined. This problem is not handled properly.

image

@OBrink
Copy link
Collaborator

OBrink commented Sep 18, 2023

PR #78 fixes this. Thank you @Iagea for reporting this problem, and sorry again for the late response!

Kohulan added a commit that referenced this issue Sep 18, 2023
…nation

fix: handle failed mask center determination #63
@OBrink OBrink closed this as completed Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants