Run this model with HF Jobs
Run OpenGVLab/InternVL-14B-224px on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/OpenGVLab/InternVL-14B-224px. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/OpenGVLab/InternVL-14B-224px on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use OpenGVLab/InternVL-14B-224px with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenGVLab/InternVL-14B-224px with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-feature-extraction", model="OpenGVLab/InternVL-14B-224px", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModel processor = AutoProcessor.from_pretrained("OpenGVLab/InternVL-14B-224px", trust_remote_code=True) model = AutoModel.from_pretrained("OpenGVLab/InternVL-14B-224px", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files123---license: mit---12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758---license: mit---```pythonimport torchfrom PIL import Imagefrom transformers import AutoModel, CLIPImageProcessorfrom transformers import AutoTokenizermodel = AutoModel.from_pretrained('OpenGVLab/InternVL-14B-224px',torch_dtype=torch.bfloat16,low_cpu_mem_usage=True,trust_remote_code=True).cuda().eval()image_processor = CLIPImageProcessor.from_pretrained('OpenGVLab/InternVL-14B-224px')tokenizer = AutoTokenizer.from_pretrained('OpenGVLab/InternVL-14B-224px', use_fast=False, add_eos_token=True)tokenizer.pad_token_id = 0 # set pad_token_id to 0images = [Image.open('./examples/image1.jpg').convert('RGB'),Image.open('./examples/image2.jpg').convert('RGB'),Image.open('./examples/image3.jpg').convert('RGB')]prefix = 'summarize:'texts = [prefix + 'a photo of a red panda', # Englishprefix + '一张熊猫的照片', # Chineseprefix + '二匹の猫の写真' # Japanese]pixel_values = image_processor(images=images, return_tensors='pt').pixel_valuespixel_values = pixel_values.to(torch.bfloat16).cuda()input_ids = tokenizer(texts, return_tensors='pt', max_length=80,truncation=True, padding='max_length').input_ids.cuda()# InternVL-Clogits_per_image, logits_per_text = model(image=pixel_values, text=input_ids, mode='InternVL-C')probs = logits_per_image.softmax(dim=-1)# tensor([[9.9609e-01, 5.2185e-03, 6.0070e-08],# [2.2949e-02, 9.7656e-01, 5.9903e-06],# [3.2932e-06, 7.4863e-05, 1.0000e+00]], device='cuda:0',# dtype=torch.bfloat16, grad_fn=<SoftmaxBackward0>)# InternVL-Glogits_per_image, logits_per_text = model(image=pixel_values, text=input_ids, mode='InternVL-G')probs = logits_per_image.softmax(dim=-1)# tensor([[9.9609e-01, 3.1738e-03, 3.6322e-08],# [8.6060e-03, 9.9219e-01, 2.8759e-06],# [1.7583e-06, 3.1233e-05, 1.0000e+00]], device='cuda:0',# dtype=torch.bfloat16, grad_fn=<SoftmaxBackward0>)```
README.md+55