Comments (5)
Hello, although this is not currently enabled with this repo we think this is feasible.
Say you have an image x
and a huge bank of possible captions t_1,...,t_n
.
You could get image/text features by running everything through CLIP, e.g. f_im = model.encode_image(x)
and text features for f_j = model.encode_text(t_j)
for j
in 1,...,n
.
Then you could use a nearest neighbors library like faiss to find the nearest neighbor between f_j
for j
in 1,...,n
and f_im
.
That nearest neighbor could be used as the generated words for that image.
from open_clip.
Alternatively, if you don't have bank of possible captions, you can try performing an automated search for the prompts that maximize agreement with the image. A good starting point is the method from Shin et al., 2020 (https://arxiv.org/abs/2010.15980)
from open_clip.
https://ucinlp.github.io/autoprompt/
With a bit of github digging for "faiss clip" - got a hit on this repo by @ps-auxw.
It seems like he has done it - https://github.com/ps-auxw/CLI-P
I'll ask if @ps-auxw can integrate his repo to use this open_clip.
UPDATE - so if anyone's interested there's a neat way to install faiss using just pip -
https://pypi.org/project/faiss-gpu/
this repo above has 2 steps -
- build-index.py / just from images.
- query-index.py / just query the index built from step 1.
"Say you have an image x and a huge bank of possible captions t_1,...,t_n."
Here is said dataset / 12million captions....
https://github.com/google-research-datasets/conceptual-12m
UPDATE 2.
This repo - https://github.com/johndpope/rerank/blob/main/data/prepare_data.py
seems to do take captions +( from variety of datasets) and images / indexes them and includes some retrieval via knearest.
https://github.com/RitaRamo/rerank/blob/993fb49df843ba8c5a3567aa97c0e5382ecbe48e/src/toolkit/data/datasets.py
def retrieve_nearest_for_train_query(self, query_img, k=2):
UPDATE 3.
found this - which looks more scalable than option 2.
https://github.com/rom1504/clip-retrieval
from open_clip.
I believe this does it
https://github.com/dzryk/clip-grams
from open_clip.
great thanks for linking!
from open_clip.
Related Issues (20)
- How to load Clip-VIT-bigG-14 in local which has two .bin files and can not find any information how to load, thanks!!!!!!! HOT 2
- How to extract 1024 width patch embeddings and CLS embedding HOT 1
- S3 Broken Pipe Error HOT 10
- A NotImplementedError occurred when I imported the pre-trained weights of RN50.
- RuntimeError: Boolean value of Tensor with more than one value is ambiguous HOT 8
- CPU memory leak when training with CsvDataset-like dataset HOT 10
- datasets for pretrained models HOT 3
- unlocking layer groups in open_clip/src/open_clip /timm_model.py for fine-tuning HOT 1
- Long context CLIP HOT 3
- How to initialize the encoder to pretrain CLIP? HOT 1
- Training speed slow HOT 1
- The result is random HOT 2
- Load hybrid-clip in open_clip HOT 1
- CoCa RoBERTa Attention Map Size Issue HOT 1
- Issue with inference values with 'hf-hub:laion/CLIP-convnext_xxlarge-laion2B-s34B-b82K-augreg' HOT 3
- What is the max value for unlocked_groups in TimmModel.lock()? I am trying to fine-tune the entire vision tower HOT 1
- [1,512] Data conversion
- Handling Negative Pairs in Fine-Tuning of CLIP Models HOT 1
- [1,512] data HOT 1
- How to inference trained checkpoint on my own dataset?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from open_clip.