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] apply_model: "Ignoring num_workers parameter; only supported for Torch models" despite using torch models #5222

Open
1 of 3 tasks
daniel-bogdoll opened this issue Dec 5, 2024 · 0 comments
Labels
bug Bug fixes

Comments

@daniel-bogdoll
Copy link

daniel-bogdoll commented Dec 5, 2024

Describe the problem

While running a set of torch models with apply_model from https://docs.voxel51.com/model_zoo/models.html#torch-models, I noticed that none support the num_workers parameters. This seems odd, since all are torch models. Either the warning message is off or there is something else going on.

Code to reproduce issue

I looked where you check for the usability of num_workers and it seems like a TorchModelMixin type is expected.

Relevant sections seem to be

However, none of the models seem to have it:

import fiftyone as fo
import fiftyone.zoo as foz
import traceback

dataset = foz.load_zoo_dataset("quickstart", max_samples=10)
model_names = ["detection-transformer-torch", "faster-rcnn-resnet50-fpn-coco-torch", "yolo11l-coco-torch", "yolov5l-coco-torch", "yolov8l-oiv7-torch", "yolov8s-world-torch"]
models = []
for model_name in model_names:
  model = foz.load_zoo_model(model_name)
  models.append(model)

import fiftyone.core.media as fom

# https://github.com/voxel51/fiftyone/blob/1649f2f2e9a98f7499d08921dbc8e9ac050732c2/fiftyone/core/models.py#L2277C1-L2287C9
class TorchModelMixin(object):
    pass

for model in models:
  print(type(model))
  # https://github.com/voxel51/fiftyone/blob/1649f2f2e9a98f7499d08921dbc8e9ac050732c2/fiftyone/core/models.py#L870
  use_data_loader = (isinstance(model, TorchModelMixin) and dataset.media_type == fom.IMAGE)
  print(use_data_loader)

gives

<class 'fiftyone.utils.transformers.FiftyOneTransformerForObjectDetection'>
False
<class 'fiftyone.zoo.models.torch.TorchvisionImageModel'>
False
<class 'fiftyone.utils.ultralytics.FiftyOneYOLODetectionModel'>
False
<class 'fiftyone.utils.torch.TorchImageModel'>
False
<class 'fiftyone.utils.ultralytics.FiftyOneYOLODetectionModel'>
False
<class 'fiftyone.utils.ultralytics.FiftyOneYOLODetectionModel'>
False

So when running

import re
# Does not seem to leverage GPU ?
# Ignores 'num_workers' despite using torch model
for model, model_name in zip(models, model_names):
  label_field = re.sub(r"[\W-]+", "_", "pred_" + model_name)
  dataset.apply_model(model, label_field=label_field, batch_size=8, num_workers=8)

the following warnings appear:

Ignoring `num_workers` parameter; only supported for Torch models
WARNING:fiftyone.core.models:Ignoring `num_workers` parameter; only supported for Torch models

So either by "Torch models" you do not mean the ones you provide in the Zoo, or something is off.

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 22.04): Google Colab T4 Instance
  • Python version (python --version): Python 3.10.12
  • FiftyOne version (fiftyone --version): FiftyOne v1.0.2, Voxel51, Inc.
  • FiftyOne installed from (pip or source): pip

Willingness to contribute

The FiftyOne Community encourages bug fix contributions. Would you or another
member of your organization be willing to contribute a fix for this bug to the
FiftyOne codebase?

  • Yes. I can contribute a fix for this bug independently
  • Yes. I would be willing to contribute a fix for this bug with guidance
    from the FiftyOne community
  • No. I cannot contribute a bug fix at this time
@daniel-bogdoll daniel-bogdoll added the bug Bug fixes label Dec 5, 2024
@daniel-bogdoll daniel-bogdoll changed the title [BUG] Ignoring num_workers parameter; only supported for Torch models despite using torch models [BUG] apply_model: "Ignoring num_workers parameter; only supported for Torch models" despite using torch models Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug fixes
Projects
None yet
Development

No branches or pull requests

1 participant