Skip to content

generate_image_prompts.py unnecessary txt embeddings#291

Open
genislm wants to merge 1 commit intoAILab-CVC:masterfrom
genislm:patch-1
Open

generate_image_prompts.py unnecessary txt embeddings#291
genislm wants to merge 1 commit intoAILab-CVC:masterfrom
genislm:patch-1

Conversation

@genislm
Copy link
Copy Markdown

@genislm genislm commented May 3, 2024

Descriptilon:

Deleted unnecessary ' ' (text) embeddings that cause a dimension error when stacked to image embeddings.

Explanation

The script to generate image embeddings was reclycled from the one used for text embeddings generation.
This causes not only unnecessary text embeddings but a bug in which a dimension error shows up.

To be more specific, the line 37 that said:
txt_feats = txt_feats.reshape(-1, txt_feats.shape[-1]).cpu().data.numpy()
Has the correct dimensions to be stored directly. However, after appending it to a list and np.stack it with the images embeddings (notice the [0] before converting it to numpy)
img_feats = img_feats.reshape(-1, img_feats.shape[-1])[0].cpu().data.numpy()
the dimensions of the np arrays to stack were not compatible.

This can be solved in two ways.

  1. change the text embedding for
    txt_feats = txt_feats.reshape(-1, txt_feats.shape[-1])[0].cpu().data.numpy() (notice the [0])
  2. Directly avoiding the text embedding, as I suggest.

Deleted unnecessary ' ' (text) embeddings that cause a dimension error when stacked to image embeddings.
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

Successfully merging this pull request may close these issues.

1 participant