upgrade sentencepiece version (#13564)
This commit is contained in:
@@ -37,10 +37,10 @@
|
||||
"OBJ_URL = \"https://raw.githubusercontent.com/airsplay/py-bottom-up-attention/master/demo/data/genome/1600-400-20/objects_vocab.txt\"\n",
|
||||
"ATTR_URL = \"https://raw.githubusercontent.com/airsplay/py-bottom-up-attention/master/demo/data/genome/1600-400-20/attributes_vocab.txt\"\n",
|
||||
"VQA_URL = \"https://dl.fbaipublicfiles.com/pythia/data/answers_vqa.txt\"\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# for visualizing output\n",
|
||||
"def showarray(a, fmt='jpeg'):\n",
|
||||
"def showarray(a, fmt=\"jpeg\"):\n",
|
||||
" a = np.uint8(np.clip(a, 0, 255))\n",
|
||||
" f = io.BytesIO()\n",
|
||||
" PIL.Image.fromarray(a).save(f, fmt)\n",
|
||||
@@ -82,7 +82,7 @@
|
||||
"image_preprocess = Preprocess(frcnn_cfg)\n",
|
||||
"\n",
|
||||
"bert_tokenizer = BertTokenizerFast.from_pretrained(\"bert-base-uncased\")\n",
|
||||
"visualbert_vqa = VisualBertForQuestionAnswering.from_pretrained(\"uclanlp/visualbert-vqa\")\n"
|
||||
"visualbert_vqa = VisualBertForQuestionAnswering.from_pretrained(\"uclanlp/visualbert-vqa\")"
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
@@ -104,17 +104,17 @@
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"source": [
|
||||
"#image viz\n",
|
||||
"# image viz\n",
|
||||
"frcnn_visualizer = SingleImageViz(URL, id2obj=objids, id2attr=attrids)\n",
|
||||
"# run frcnn\n",
|
||||
"images, sizes, scales_yx = image_preprocess(URL)\n",
|
||||
"output_dict = frcnn(\n",
|
||||
" images, \n",
|
||||
" sizes, \n",
|
||||
" scales_yx=scales_yx, \n",
|
||||
" images,\n",
|
||||
" sizes,\n",
|
||||
" scales_yx=scales_yx,\n",
|
||||
" padding=\"max_detections\",\n",
|
||||
" max_detections=frcnn_cfg.max_detections,\n",
|
||||
" return_tensors=\"pt\"\n",
|
||||
" return_tensors=\"pt\",\n",
|
||||
")\n",
|
||||
"# add boxes and labels to the image\n",
|
||||
"\n",
|
||||
@@ -167,7 +167,7 @@
|
||||
" \"What is the shape of the monitor?\",\n",
|
||||
"]\n",
|
||||
"\n",
|
||||
"#Very important that the boxes are normalized\n",
|
||||
"# Very important that the boxes are normalized\n",
|
||||
"# normalized_boxes = output_dict.get(\"normalized_boxes\")\n",
|
||||
"features = output_dict.get(\"roi_features\")"
|
||||
],
|
||||
@@ -189,7 +189,7 @@
|
||||
" return_token_type_ids=True,\n",
|
||||
" return_attention_mask=True,\n",
|
||||
" add_special_tokens=True,\n",
|
||||
" return_tensors=\"pt\"\n",
|
||||
" return_tensors=\"pt\",\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" output_vqa = visualbert_vqa(\n",
|
||||
|
||||
Reference in New Issue
Block a user