Skip to content

Scalar type error when using CPU #4

@zhuangaoooo

Description

@zhuangaoooo

When using CPU to run app.py, the following error will occur

  File "/home/ao/Project/Segmentation/cliper.code/app.py", line 54, in process_image
    embedding[(fg_text_features @ embedding.T).sort().indices[:, ::1500]].flatten(0, 1)],
RuntimeError: expected scalar type Float but found Half

A way to fix it is to edit the line 52 of app.py when using CPU:

    bg_text_features = CLIPer.cliper.classifier(bg_classes, cfg.semantic_templates)
    bg_text_features = torch.cat([bg_text_features,
                                      embedding[(fg_text_features.float() @ embedding.T.float()).sort().indices[:, ::1500]].flatten(0, 1)],
                                 dim=0)
    # bg_text_features = torch.cat([bg_text_features,
    #                               embedding[(fg_text_features @ embedding.T).sort().indices[:, ::1500]].flatten(0, 1)],
    #                              dim=0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions