Add model card with installation and usage sections
#3
by nielsr HF Staff - opened
123---license: apache-2.0---123456789101112131415161718192021222324252627282930313233343536373839404142434445---license: apache-2.0pipeline_tag: zero-shot-image-classificationlibrary_name: openclip---# LongCLIP modelThis repository contains the weights of the LongCLIP model.Paper: https://huggingface.co/papers/2403.15378Github repository: https://github.com/beichenzbc/long-clip## Installation```bashgit clone https://github.com/beichenzbc/Long-CLIP.gitcd Long-CLIP```## Usage```from model import longclipimport torchfrom PIL import Imagefrom huggingface_hub import hf_hub_downloaddevice = "cuda" if torch.cuda.is_available() else "cpu"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)with torch.no_grad():image_features = model.encode_image(image)text_features = model.encode_text(text)logits_per_image = image_features @ text_features.Tprobs = logits_per_image.softmax(dim=-1).cpu().numpy()print("Label probs:", probs)```
README.md+45-3