Run this model with HF Jobs
Run damerajee/GPT-Vision 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/damerajee/GPT-Vision. 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/damerajee/GPT-Vision 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 damerajee/GPT-Vision with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use damerajee/GPT-Vision with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import GPTVision model = GPTVision.from_pretrained("damerajee/GPT-Vision", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update modeling_gpt2vision.py
Browse files67 unmodified lines68697071727374751 unmodified line777879808182838467 unmodified linesdef generate(self, question, image, max_new_tokens=30, **kwargs):# Process the imageimg_embs = self.vision_encoder(image, device=self.device)img_embs = self.mlp(img_embs)# Tokenize the questionprompt = f"{IMAGE_TOKEN}Question: {question}\nAnswer:"1 unmodified linebatch = {"pixel_values": img_embs,"input_ids": encoded_input.input_ids,"attention_mask": encoded_input.attention_mask}inputs_embeds, attention_mask, input_ids = self.preprocess_inputs(batch)67 unmodified lines68697071727374757677781 unmodified line808182838485868767 unmodified linesdef generate(self, question, image, max_new_tokens=30, **kwargs):# Process the image# Convert the image to a tensor and add a batch dimensionimage_tensor = self.vision_encoder.image_transform(image).unsqueeze(0).to(self.device)with torch.no_grad():img_features = self.vision_model(image_tensor).last_hidden_stateimg_embs = self.mlp(img_features)# Tokenize the questionprompt = f"{IMAGE_TOKEN}Question: {question}\nAnswer:"1 unmodified linebatch = {"pixel_values": img_embs,"input_ids": encoded_input.input_ids.to(self.device),"attention_mask": encoded_input.attention_mask.to(self.device)}inputs_embeds, attention_mask, input_ids = self.preprocess_inputs(batch)
modeling_gpt2vision.py+7-4