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

ValueError: Found array with 1 sample(s) (shape=(1, 2)) while a minimum of 2 is required by AgglomerativeClustering. #71

Open
timtsm opened this issue Jan 26, 2025 · 0 comments

Comments

@timtsm
Copy link

timtsm commented Jan 26, 2025

Describe the bug
I'm trying to process the attached image. I get the error in the title (ValueError: Found array with 1 sample(s) (shape=(1, 2)) while a minimum of 2 is required by AgglomerativeClustering.) in the analyzing notehead boxes stage, and no output file. There are a few warnings beforehand so I am including the whole output. This is on a macbook pro (2022, M2).

Input Image

Image

Full Traceback

2025-01-26 18:13:39 Extracting staffline and symbols
2025-01-26 18:13:39.606156 [W:onnxruntime:, coreml_execution_provider.cc:115 GetCapability] CoreMLExecutionProvider::GetCapability, number of partitions supported by CoreML: 86 number of nodes in the graph: 1577 number of nodes supported by CoreML: 102
2766 1328
Context leak detected, msgtracer returned -1
Context leak detected, msgtracer returned -1
2025-01-26 18:15:23 Extracting layers of different symbols
2025-01-26 18:15:23.490085 [W:onnxruntime:, coreml_execution_provider.cc:115 GetCapability] CoreMLExecutionProvider::GetCapability, number of partitions supported by CoreML: 94 number of nodes in the graph: 1619 number of nodes supported by CoreML: 107
2766 1328
Context leak detected, msgtracer returned -1
Context leak detected, msgtracer returned -1
2025-01-26 18:18:21 Extracting stafflines
/Users/tim/src/oemer/ve/lib/python3.12/site-packages/numpy/_core/fromnumeric.py:3596: RuntimeWarning: Mean of empty slice.
  return _methods._mean(a, axis=axis, dtype=dtype,
/Users/tim/src/oemer/ve/lib/python3.12/site-packages/numpy/_core/_methods.py:138: RuntimeWarning: invalid value encountered in scalar divide
  ret = ret.dtype.type(ret / rcount)
70 404 4
405 739 4
740 1074 4
1075 1409 4
1410 1744 4
1745 2079 4
2080 2414 4
2415 2749 4
Centers of staff parts at the same row not aligned (Th: 0.1): [0.01716697 0.01716652 0.12034679 0.01715335 0.01735288 0.01711578
 0.01709273 0.01729857]
2025-01-26 18:18:22 Extracting noteheads
2025-01-26 18:18:22 Analyzing notehead bboxes
Traceback (most recent call last):
  File "/Users/tim/src/oemer/ve/bin/oemer", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/tim/src/oemer/ve/lib/python3.12/site-packages/oemer/ete.py", line 287, in main
    mxl_path = extract(args)
               ^^^^^^^^^^^^^
  File "/Users/tim/src/oemer/ve/lib/python3.12/site-packages/oemer/ete.py", line 184, in extract
    notes = note_extract()
            ^^^^^^^^^^^^^^
  File "/Users/tim/src/oemer/ve/lib/python3.12/site-packages/oemer/notehead_extraction.py", line 440, in extract
    merged_box = merge_nearby_bbox(bboxes, distance=unit_size*max_whole_note_width_factor, y_factor=y_dist_factor)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tim/src/oemer/ve/lib/python3.12/site-packages/oemer/bbox.py", line 42, in merge_nearby_bbox
    model.fit(centers)
  File "/Users/tim/src/oemer/ve/lib/python3.12/site-packages/sklearn/base.py", line 1389, in wrapper
    return fit_method(estimator, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tim/src/oemer/ve/lib/python3.12/site-packages/sklearn/cluster/_agglomerative.py", line 988, in fit
    X = validate_data(self, X, ensure_min_samples=2)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tim/src/oemer/ve/lib/python3.12/site-packages/sklearn/utils/validation.py", line 2944, in validate_data
    out = check_array(X, input_name="X", **check_params)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tim/src/oemer/ve/lib/python3.12/site-packages/sklearn/utils/validation.py", line 1130, in check_array
    raise ValueError(
ValueError: Found array with 1 sample(s) (shape=(1, 2)) while a minimum of 2 is required by AgglomerativeClustering.

Command You Execute
oemer -d ~/Downloads/ppmusic.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant