huggingface / transformers

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
https://huggingface.co/transformers
Apache License 2.0
134.17k stars 26.83k forks source link

How to use 【examples/pytorch/contrastive-image-text】 to inter inference #32873

Open rendaoyuan opened 2 months ago

rendaoyuan commented 2 months ago

Feature request

I have reviewed the training code for CLIP and successfully executed it. Now, I want to use the obtained model for inference testing.

Motivation

I would like to test the performance of the model I have trained.

Your contribution

I hope I can get a example script to inference testing like below script :

python examples/pytorch/contrastive-image-text/run_clip.py \ --output_dir ./clip-roberta-finetuned \ --model_name_or_path ./clip-roberta \ --data_dir $PWD/data \ --dataset_name ydshieh/coco_dataset_script \ --dataset_config_name=2017 \ --image_column image_path \ --caption_column caption \ --remove_unused_columns=False \ --do_train --do_eval \ --per_device_train_batch_size="64" \ --per_device_eval_batch_size="64" \ --learning_rate="5e-5" --warmup_steps="0" --weight_decay 0.1 \ --overwrite_output_dir \ --push_to_hub

NielsRogge commented 2 months ago

Hi,

Inference can be done as shown here (just pass the folder containing your weights and config.json to the from_pretrained method).