UncleFish commited on
Commit
e980750
1 Parent(s): f079e7b

update demo example

Browse files
Files changed (1) hide show
  1. demo.ipynb +19 -4
demo.ipynb CHANGED
@@ -193,16 +193,24 @@
193
  },
194
  {
195
  "cell_type": "code",
196
- "execution_count": null,
197
  "metadata": {},
198
- "outputs": [],
 
 
 
 
 
 
 
 
199
  "source": [
200
  "import requests\n",
201
  "from PIL import Image\n",
202
  "img_url = 'https://storage.googleapis.com/sfr-vision-language-research/BLIP/demo.jpg'\n",
203
- "raw_image = Image.open(requests.get(img_url, stream=True).raw).convert('RGB')\n",
204
  "query = \"how many dogs are in the picture?\"\n",
205
- "inputs = image_processor([img], return_tensors=\"pt\", image_aspect_ratio='anyres')\n",
206
  "prompt = apply_prompt_template(query)\n",
207
  "language_inputs = tokenizer([prompt], return_tensors=\"pt\")\n",
208
  "inputs.update(language_inputs)\n",
@@ -216,6 +224,13 @@
216
  "print(\"==> prediciton: \", prediction)\n",
217
  "# output: ==> prediciton: There is one dog in the picture."
218
  ]
 
 
 
 
 
 
 
219
  }
220
  ],
221
  "metadata": {
 
193
  },
194
  {
195
  "cell_type": "code",
196
+ "execution_count": 12,
197
  "metadata": {},
198
+ "outputs": [
199
+ {
200
+ "name": "stdout",
201
+ "output_type": "stream",
202
+ "text": [
203
+ "==> prediciton: There is one dog in the picture.\n"
204
+ ]
205
+ }
206
+ ],
207
  "source": [
208
  "import requests\n",
209
  "from PIL import Image\n",
210
  "img_url = 'https://storage.googleapis.com/sfr-vision-language-research/BLIP/demo.jpg'\n",
211
+ "raw_image = Image.open(requests.get(img_url, stream=True).raw)\n",
212
  "query = \"how many dogs are in the picture?\"\n",
213
+ "inputs = image_processor([raw_image], return_tensors=\"pt\", image_aspect_ratio='anyres')\n",
214
  "prompt = apply_prompt_template(query)\n",
215
  "language_inputs = tokenizer([prompt], return_tensors=\"pt\")\n",
216
  "inputs.update(language_inputs)\n",
 
224
  "print(\"==> prediciton: \", prediction)\n",
225
  "# output: ==> prediciton: There is one dog in the picture."
226
  ]
227
+ },
228
+ {
229
+ "cell_type": "code",
230
+ "execution_count": null,
231
+ "metadata": {},
232
+ "outputs": [],
233
+ "source": []
234
  }
235
  ],
236
  "metadata": {