UForm-Gen is a small generative vision-language model primarily designed for Image Captioning and Visual Question Answering. The model consists of two parts:
The model was pre-trained on: MSCOCO, SBU Captions, Visual Genome, VQAv2, GQA and a few internal datasets.
The generative model can be used to caption images, summarize their content, or answer questions about them.
The exact behavior is controlled by prompts.
1from uform.gen_model import VLMForCausalLM, VLMProcessor
2
3model = VLMForCausalLM.from_pretrained("unum-cloud/uform-gen")
4processor = VLMProcessor.from_pretrained("unum-cloud/uform-gen")
5
6# [cap] Narrate the contents of the image with precision.
7# [cap] Summarize the visual content of the image.
8# [vqa] What is the main subject of the image?
9prompt = "[cap] Summarize the visual content of the image."
10image = Image.open("zebra.jpg")
11
12inputs = processor(texts=[prompt], images=[image], return_tensors="pt")
13with torch.inference_mode():
14 output = model.generate(
15 **inputs,
16 do_sample=False,
17 use_cache=True,
18 max_new_tokens=128,
19 eos_token_id=32001,
20 pad_token_id=processor.tokenizer.pad_token_id
21 )
22
23prompt_len = inputs["input_ids"].shape[1]
24decoded_text = processor.batch_decode(output[:, prompt_len:])[0]
For captioning evaluation we measure CLIPScore and RefCLIPScore¹.
Results for VQAv2 evaluation.
On RTX 3090, the following performance is expected on text token generation using float16, equivalent PyTorch settings, and greedy decoding.