From d06ceef9ea282b5e90f56bcc40f5de331f048c0e Mon Sep 17 00:00:00 2001 From: Niels Date: Mon, 30 Sep 2024 14:40:24 +0200 Subject: [PATCH 1/2] First draft --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3f29afd..97c53f9 100644 --- a/README.md +++ b/README.md @@ -49,15 +49,18 @@ git clone https://github.com/beichenzbc/Long-CLIP.git cd Long-CLIP ``` -Then, download the checkpoints of our model [LongCLIP-B](https://huggingface.co/BeichenZhang/LongCLIP-B) and/or [LongCLIP-L](https://huggingface.co/BeichenZhang/LongCLIP-L) and place it under `./checkpoints` +Then, download the checkpoints of our model [LongCLIP-B](https://huggingface.co/BeichenZhang/LongCLIP-B) and/or [LongCLIP-L](https://huggingface.co/BeichenZhang/LongCLIP-L) as shown below: ```python from model import longclip import torch from PIL import Image +from huggingface_hub import hf_hub_download device = "cuda" if torch.cuda.is_available() else "cpu" -model, preprocess = longclip.load("./checkpoints/longclip-B.pt", device=device) +# here we download LongCLIP-L +filepath = hf_hub_download(repo_id="BeichenZhang/LongCLIP-L", filename="longclip-L.pt") +model, preprocess = longclip.load(filepath, device=device) text = longclip.tokenize(["A man is crossing the street with a red car parked nearby.", "A man is driving a car in an urban scene."]).to(device) image = preprocess(Image.open("./img/demo.png")).unsqueeze(0).to(device) From f058f8af13aee79bc78caeae775e77c60beb57f4 Mon Sep 17 00:00:00 2001 From: Niels Date: Mon, 30 Sep 2024 14:43:13 +0200 Subject: [PATCH 2/2] Improve --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 97c53f9..4676794 100644 --- a/README.md +++ b/README.md @@ -39,17 +39,16 @@ This repository is the official implementation of Long-CLIP Our model is based on [CLIP](https://github.com/openai/CLIP), please prepare environment for CLIP. - -### how to use - -Please first clone our [repo](https://github.com/beichenzbc/Long-CLIP) from github by running the following command. +Next, clone our [repo](https://github.com/beichenzbc/Long-CLIP) from Github by running the following command. ```shell git clone https://github.com/beichenzbc/Long-CLIP.git cd Long-CLIP ``` -Then, download the checkpoints of our model [LongCLIP-B](https://huggingface.co/BeichenZhang/LongCLIP-B) and/or [LongCLIP-L](https://huggingface.co/BeichenZhang/LongCLIP-L) as shown below: +### how to use + +Then, download the checkpoints of our model [LongCLIP-B](https://huggingface.co/BeichenZhang/LongCLIP-B) and/or [LongCLIP-L](https://huggingface.co/BeichenZhang/LongCLIP-L) from 🤗 Hugging Face as shown below: ```python from model import longclip