{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "116eb01e", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "ac6c81923ae642dda82e7be3d8b8172c", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Loading pipeline components...: 0%| | 0/9 [00:00)" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "torch.nn.functional.cosine_similarity(feature, text_feature[0][:,:77].mean(1).to(device)) " ] }, { "cell_type": "code", "execution_count": 13, "id": "faf28cbe", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(torch.Size([1, 77, 2048]), torch.Size([1, 1792]))" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "clip_prompt_embeds.shape, torch.cat([image_features_l, image_features_g], dim=1).shape " ] }, { "cell_type": "code", "execution_count": 14, "id": "44e2cd9c", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "tensor([0.0223], device='cuda:0', grad_fn=)" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "torch.nn.functional.cosine_similarity(feature.mean(1), text_feature[0][:,:77].mean(1).to(device)) " ] } ], "metadata": { "kernelspec": { "display_name": "neg", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.17" } }, "nbformat": 4, "nbformat_minor": 5 }