soldni commited on
Commit
89330e2
1 Parent(s): ef6a2da

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +50 -0
README.md CHANGED
@@ -131,6 +131,56 @@ print(generated_text)
131
 
132
  *Benchmarks: AI2D test, ChartQA test, VQA v2.0 test, DocQA test, InfographicVQA test, TextVQA val, RealWorldQA, MMMU val, MathVista testmini, CountBenchQA, Flickr Count (we collected this new dataset that is significantly harder than CountBenchQA).*
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  ## License and Use
135
 
136
  This model is licensed under Apache 2.0. It is intended for research and educational use.
 
131
 
132
  *Benchmarks: AI2D test, ChartQA test, VQA v2.0 test, DocQA test, InfographicVQA test, TextVQA val, RealWorldQA, MMMU val, MathVista testmini, CountBenchQA, Flickr Count (we collected this new dataset that is significantly harder than CountBenchQA).*
133
 
134
+ ### I'm getting an error a broadcast error when processing images!
135
+
136
+ Your image might not be in RGB format. You can convert it using the following code snippet:
137
+
138
+ ```python
139
+ from PIL import Image
140
+
141
+ image = Image.open(...)
142
+
143
+ if image.mode != "RGB":
144
+ image = image.convert("RGB")
145
+ ```
146
+
147
+ ### Molmo doesn't work great with transparent images!
148
+
149
+ We received reports that Molmo models might struggle with transparent images.
150
+ For the time being, we recommend adding a white or dark background to your images before passing them to the model. The code snippet below shows how to do this using the Python Imaging Library (PIL):
151
+
152
+ ```python
153
+
154
+ # Load the image
155
+ url = "..."
156
+ image = Image.open(requests.get(url, stream=True).raw)
157
+
158
+ # Convert the image to grayscale to calculate brightness
159
+ gray_image = image.convert('L') # Convert to grayscale
160
+
161
+ # Calculate the average brightness
162
+ stat = ImageStat.Stat(gray_image)
163
+ average_brightness = stat.mean[0] # Get the average value
164
+
165
+ # Define background color based on brightness (threshold can be adjusted)
166
+ bg_color = (0, 0, 0) if average_brightness > 127 else (255, 255, 255)
167
+
168
+ # Create a new image with the same size as the original, filled with the background color
169
+ new_image = Image.new('RGB', image.size, bg_color)
170
+
171
+ # Paste the original image on top of the background (use image as a mask if needed)
172
+ new_image.paste(image, (0, 0), image if image.mode == 'RGBA' else None)
173
+
174
+ # Now you can pass the new_image to Molmo
175
+ processor = AutoProcessor.from_pretrained(
176
+ 'allenai/Molmo-7B-D-0924',
177
+ trust_remote_code=True,
178
+ torch_dtype='auto',
179
+ device_map='auto'
180
+ )
181
+ ```
182
+
183
+
184
  ## License and Use
185
 
186
  This model is licensed under Apache 2.0. It is intended for research and educational use.