comin commited on
Commit
f2d9583
·
verified ·
1 Parent(s): 2323e42

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +73 -0
README.md CHANGED
@@ -13,6 +13,79 @@ We introduce **Generative Universal Verifier**, a novel concept and plugin desig
13
 
14
  OmniVerifier advances both reliable reflection during generation and scalable test-time refinement, marking a step toward more trustworthy and controllable next-generation reasoning systems.
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  ```
18
  @article{zhang2025generative,
 
13
 
14
  OmniVerifier advances both reliable reflection during generation and scalable test-time refinement, marking a step toward more trustworthy and controllable next-generation reasoning systems.
15
 
16
+ ### Quick Start: Generated Image Verification
17
+
18
+ Use the following code to test **OmniVerifier-7B** on a generated image:
19
+
20
+ Please modify `image_path` and `prompt` to your own settings.
21
+
22
+ The model will output both an **answer** and an **explanation**, indicating whether the image is strictly aligned with the given prompt.
23
+
24
+ ```python
25
+ import torch
26
+ from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, AutoProcessor
27
+ from qwen_vl_utils import process_vision_info
28
+
29
+ # default: Load the model on the available device(s)
30
+ model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
31
+ "comin/OmniVerifier-7B", torch_dtype=torch.bfloat16, device_map="auto"
32
+ )
33
+ # default processer
34
+ processor = AutoProcessor.from_pretrained("comin/OmniVerifier-7B")
35
+
36
+ image_path = '' # please replace it with your own image path
37
+ prompt = '' # please replace it with the prompt you use to generate the image
38
+
39
+ question = f"""This image was generated from the prompt: {prompt}.
40
+ Please carefully analyze the image and determine whether all the objects, attributes, and spatial relationships mentioned in the prompt are correctly represented in the image.
41
+
42
+ If the image accurately reflects the prompt, please answer 'true'; otherwise, answer 'false'.
43
+
44
+ Respond strictly in the following JSON format: """ + """
45
+
46
+ {
47
+ "answer": true/false,
48
+ "explanation": "If the answer is false, briefly summarize the main error.",
49
+ }
50
+ """
51
+
52
+ messages = [
53
+ {
54
+ "role": "user",
55
+ "content": [
56
+ {
57
+ "type": "image",
58
+ "image": image_path,
59
+ },
60
+ {"type": "text", "text": question},
61
+ ],
62
+ }
63
+ ]
64
+
65
+ # Preparation for inference
66
+ text = processor.apply_chat_template(
67
+ messages, tokenize=False, add_generation_prompt=True
68
+ )
69
+ image_inputs, video_inputs = process_vision_info(messages)
70
+ inputs = processor(
71
+ text=[text],
72
+ images=image_inputs,
73
+ videos=video_inputs,
74
+ padding=True,
75
+ return_tensors="pt",
76
+ )
77
+ inputs = inputs.to("cuda")
78
+
79
+ # Inference: Generation of the output
80
+ generated_ids = model.generate(**inputs, max_new_tokens=128)
81
+ generated_ids_trimmed = [
82
+ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
83
+ ]
84
+ output_text = processor.batch_decode(
85
+ generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
86
+ )
87
+ print(output_text)
88
+ ```
89
 
90
  ```
91
  @article{zhang2025generative,