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

[BUG] compute_visualization does not accept dict-valued 'points' kwarg when method='manual' #3268

Closed
1 of 3 tasks
allenleetc opened this issue Jul 8, 2023 · 1 comment
Closed
1 of 3 tasks
Labels
bug Bug fixes ml An issue that involves a machine learning concept

Comments

@allenleetc
Copy link
Contributor

allenleetc commented Jul 8, 2023

System information

  • OS Platform and Distribution Ubuntu 20.0.4
  • Python version (python --version): 3.10
  • FiftyOne version (fiftyone --version): 0.21.2
  • FiftyOne installed from (pip or source): pip

Commands to reproduce

import numpy as np
import fiftyone as fo
import fiftyone.zoo as foz
import fiftyone.brain as fob

dataset = foz.load_zoo_dataset('quickstart')
ids = dataset.values('id')
id_dict = {x: np.random.rand(2) for x in ids}
fob.compute_visualization(dataset, brain_key="bkey", method="manual", points=id_dict)

Throws

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[57], line 3
      1 ids = ds.values('id')
      2 id_dict = {x: np.random.rand(2) for x in ids}
----> 3 fob.compute_visualization(ds, brain_key="bkey", method="manual", points=id_dict)

File ~/fot.1.3.dc/fot_1_3_dc/lib/python3.10/site-packages/fiftyone/brain/__init__.py:376, in compute_visualization(samples, patches_field, embeddings, points, brain_key, num_dims, method, model, force_square, alpha, batch_size, num_workers, skip_failures, **kwargs)
    267 """Computes a low-dimensional representation of the samples' media or their
    268 patches that can be interactively visualized.
    269 
   (...)
    372     a :class:`fiftyone.brain.visualization.VisualizationResults`
    373 """
    374 import fiftyone.brain.internal.core.visualization as fbv
--> 376 return fbv.compute_visualization(
    377     samples,
    378     patches_field,
    379     embeddings,
    380     points,
    381     brain_key,
    382     num_dims,
    383     method,
    384     model,
    385     force_square,
    386     alpha,
    387     batch_size,
    388     num_workers,
    389     skip_failures,
    390     **kwargs,
    391 )

File ~/fot.1.3.dc/fot_1_3_dc/lib/python3.10/site-packages/fiftyone/brain/internal/core/visualization.py:71, in compute_visualization(samples, patches_field, embeddings, points, brain_key, num_dims, method, model, force_square, alpha, batch_size, num_workers, skip_failures, **kwargs)
     69     embeddings = None
     70     embeddings_field = None
---> 71     num_dims = points.shape[1]
     72 elif model is None and embeddings is None:
     73     model = _DEFAULT_MODEL

AttributeError: 'dict' object has no attribute 'shape'

Describe the problem

The doc at https://docs.voxel51.com/api/fiftyone.brain.html#fiftyone.brain.compute_visualization suggests that the points kwarg can be a dict mapping sample ids -> vectors, but this isn't accepted.

What areas of FiftyOne does this bug affect?

  • App: FiftyOne application issue
  • Core: Core Python library issue
  • Server: FiftyOne server issue
@allenleetc allenleetc added bug Bug fixes ml An issue that involves a machine learning concept labels Jul 8, 2023
@brimoor brimoor closed this as completed Jul 10, 2023
@brimoor
Copy link
Contributor

brimoor commented Jul 10, 2023

This will be fixed in fiftyone==0.21.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug fixes ml An issue that involves a machine learning concept
Projects
None yet
Development

No branches or pull requests

2 participants