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

generate_image_prompts.py unnecessary txt embeddings #291

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

elokquence
Copy link

@elokquence elokquence 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