Zero-Shot Image Classification
OpenCLIP
English
clip
biology
CV
images
animals
species
taxonomy
rare species
endangered species
evolutionary biology
multimodal
knowledge-guided
Instructions to use imageomics/bioclip with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- OpenCLIP
How to use imageomics/bioclip with OpenCLIP:
import open_clip model, preprocess_train, preprocess_val = open_clip.create_model_and_transforms('hf-hub:imageomics/bioclip') tokenizer = open_clip.get_tokenizer('hf-hub:imageomics/bioclip') - Notebooks
- Google Colab
- Kaggle
File size: 690 Bytes
7b4abf1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # Examples
## Zero-Shot Classification
```sh
pip install torch # whatever version you want
pip install open_clip_torch numpy tqdm torchvision
```
Suppose you want to evaluate BioCLIP on zero-shot classification on two tasks, `<DATASET-NAME>` and `<DATASET2-NAME>`.
You can use `examples/zero_shot.py` to get top1 and top5 accuracy assuming your tasks are arranged as `torchvision`'s [`ImageFolder`](https://pytorch.org/vision/stable/generated/torchvision.datasets.ImageFolder.html) wants.
```sh
python examples/zero_shot.py \
--datasets <DATASET-NAME>=<DATASET-FOLDER> <DATASET2-NAME>=<DATASET2-FOLDER>
```
This will write to `logs/bioclip-zero-shot/results.json` with your results. |