{ "cells": [ { "cell_type": "markdown", "id": "ef30cea2-9fc5-47a8-b594-95e1e3b6f8fe", "metadata": {}, "source": [ "This notebook will give an example of how to access the data and plot boxes over annotated pages." ] }, { "cell_type": "code", "execution_count": 14, "id": "7aff9540-1648-4768-a27a-d726638507ba", "metadata": {}, "outputs": [], "source": [ "data_file = './paper1_boxes.json' # where is datafile stored?\n", "\n", "save_dir = './' # where to save downloaded PDFs/images" ] }, { "cell_type": "code", "execution_count": 29, "id": "a03ed03b-72c0-4a62-b7ca-c6aee7da36bd", "metadata": {}, "outputs": [], "source": [ "# colors for each type of annotation\n", "colors = {'figure':(255,0,0), 'figure caption':(125,125,0), \n", " 'math formula':(0,255,0), 'table':(0,0,255)}" ] }, { "cell_type": "code", "execution_count": 33, "id": "24a68872-7f69-48e9-9bfc-af4ba457f1a9", "metadata": {}, "outputs": [], "source": [ "import requests\n", "import pandas as pd\n", "import wget\n", "from PIL import Image\n", "import numpy as np\n", "import cv2 as cv\n", "import matplotlib.pyplot as plt\n", "\n", "from data_utils import save_pages" ] }, { "cell_type": "code", "execution_count": 4, "id": "1a717be6-e3ca-409d-89e6-6a87dcc6e524", "metadata": {}, "outputs": [], "source": [ "df = pd.read_json(data_file)" ] }, { "cell_type": "code", "execution_count": 5, "id": "aeef0b03-3869-43cd-bedd-f97d76421959", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | pdf link | \n", "true boxes | \n", "page number | \n", "split | \n", "
---|---|---|---|---|
0 | \n", "http://articles.adsabs.harvard.edu/cgi-bin/nph... | \n", "[[0.08984375, 0.880859375, 0.501953125, 0.9238... | \n", "2 | \n", "train | \n", "
1 | \n", "http://articles.adsabs.harvard.edu/cgi-bin/nph... | \n", "[[0.11523437500000001, 0.79296875, 0.906250000... | \n", "9 | \n", "train | \n", "
2 | \n", "http://articles.adsabs.harvard.edu/cgi-bin/nph... | \n", "[[0.15625, 0.212890625, 0.2578125, 0.85546875,... | \n", "10 | \n", "train | \n", "
3 | \n", "http://articles.adsabs.harvard.edu/cgi-bin/nph... | \n", "[[0.0703125, 0.798828125, 0.9316406250000001, ... | \n", "2 | \n", "train | \n", "
4 | \n", "http://articles.adsabs.harvard.edu/cgi-bin/nph... | \n", "[[0.740234375, 0.283203125, 0.783203125, 0.666... | \n", "14 | \n", "train | \n", "