Downloads · 30 days
17
1% of all-time downloads
ryanyip7777/pmc_vit-l-14_hf
pmc_vit-l-14_hf is a zero-shot image classification model from ryanyip7777. Use it for the zero-shot image classification task on the model card, and read the license before you ship it in a product. It is set up for transformers.
should probably proofread and complete it, then remove this comment. --
Downloads · 30 days
17
1% of all-time downloads
All-time downloads
1.9K
Public
Repo size
3.4 GB
Likes
1
Public
Click a slice to open those files.
.bin1.7 GB · 100%
From the Hugging Face model README
This model is a fine-tuned version of openai/clip-vit-large-patch14 on an pmc_oa (https://huggingface.co/datasets/axiong/pmc_oa) dataset. It achieves the following results on the evaluation set:
More information needed
More information needed
More information needed
The following hyperparameters were used during training:
python -W ignore run_clip.py --model_name_or_path openai/clip-vit-large-patch14 \
--output_dir ./clip-vit-l-14-pmc-finetuned \
--train_file data/pmc_roco_train.csv \
--validation_file data/pmc_roco_valid.csv \
--image_column image --caption_column caption \
--max_seq_length 77 \
--do_train --do_eval \
--per_device_train_batch_size 16 --per_device_eval_batch_size 8 \
--remove_unused_columns=False \
--learning_rate="5e-5" --warmup_steps="0" --weight_decay 0.1 \
--overwrite_output_dir \
--num_train_epochs 10 \
--logging_dir ./pmc_vit_logs \
--save_total_limit 2 \
--report_to tensorboard
from PIL import Image
import requests
from transformers import CLIPProcessor, CLIPModel
model = CLIPModel.from_pretrained("ryanyip7777/pmc_vit-l-14_hf")
processor = CLIPProcessor.from_pretrained("ryanyip7777/pmc_vit-l-14_hf")
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
inputs = processor(text=["a photo of a cat", "a photo of a dog"], images=image, return_tensors="pt", padding=True)
outputs = model(**inputs)
logits_per_image = outputs.logits_per_image # this is the image-text similarity score
probs = logits_per_image.softmax(dim=1) # we can take the softmax to get the label probabilities