{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import copy\n", "from benchmark_nerfacto import table_rows\n", "\n", "# methods sorted in the same order we want in the paper tables\n", "methods = [row[0] for row in table_rows]" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "def csv_filename_to_results(csv_filename, num_decimals=2):\n", " # code to read the csv file\n", " # and return a dictionary\n", "\n", " df = pd.read_csv(csv_filename)\n", "\n", " column_titles = list(df.columns.values)\n", " last_row = list(df.values[-1])\n", "\n", " # print(len(column_titles))\n", " # print(len(last_row))\n", "\n", " from collections import defaultdict\n", " results = defaultdict(dict)\n", " for column_title, last_row_value in zip(column_titles, last_row):\n", " if column_title == \"Step\" or \"__MAX\" in column_title or \"__MIN\" in column_title:\n", " continue\n", " name = column_title.split(\" - \")[0]\n", " capture_name, method = name.split(\"_\")\n", " metric = float(last_row_value)\n", " # format to have 2 decimal places\n", " if num_decimals == 2:\n", " metric = f\"{metric:.2f}\"\n", " elif num_decimals == 3:\n", " metric = f\"{metric:.3f}\"\n", " results[capture_name][method] = metric\n", "\n", " # import pprint\n", " # pprint.pprint(results)\n", " # print(len(results))\n", "\n", " results = dict(results)\n", " return results" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "# the csv filenames\n", "# these are generated from exporting CSVs from wandb graphs\n", "# csv_filename_psrn = \"/home/ethanweber/nerfactory/wandb-psnr.csv\"\n", "# csv_filename_ssim = \"/home/ethanweber/nerfactory/wandb-ssim.csv\"\n", "# csv_filename_lpips = \"/home/ethanweber/nerfactory/wandb-lpips.csv\"\n", "csv_filename_psrn = \"/home/ethanweber/nerfactory/wandb-jan9-psnr.csv\"\n", "csv_filename_ssim = \"/home/ethanweber/nerfactory/wandb-jan9-ssim.csv\"\n", "csv_filename_lpips = \"/home/ethanweber/nerfactory/wandb-jan9-lpips.csv\"\n", "\n", "results_psrn = csv_filename_to_results(csv_filename_psrn)\n", "results_ssim = csv_filename_to_results(csv_filename_ssim, num_decimals=3)\n", "results_lpips = csv_filename_to_results(csv_filename_lpips, num_decimals=3)\n" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "def generate_row(method, capture_names):\n", " # remove spaces from method\n", " method_text = method.replace(\"-\", \" \")\n", " string = f\"{method_text}\"\n", " for idx, capture_name in enumerate(capture_names):\n", " psnr = results_psrn[capture_name][method]\n", " ssim = results_ssim[capture_name][method]\n", " lpips = results_lpips[capture_name][method]\n", " if idx == len(capture_names) - 1:\n", " string += \" & \\\\multicolumn{1}{r|}{\" + f\"{psnr} / {ssim} / {lpips}\" + \"}\"\n", " else:\n", " string += \" & \\\\multicolumn{1}{r}{\" + f\"{psnr} / {ssim} / {lpips}\" + \"}\"\n", " return string" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['Egypt', 'person', 'kitchen', 'plane', 'dozer']\n", "no contraction & \\multicolumn{1}{r}{18.06 / 0.520 / 0.151} & \\multicolumn{1}{r}{21.96 / 0.511 / 0.125} & \\multicolumn{1}{r}{19.35 / 0.764 / 0.078} & \\multicolumn{1}{r}{18.45 / 0.519 / 0.161} & \\multicolumn{1}{r|}{19.53 / 0.786 / 0.081} \\\\ \n", "synthetic on real & \\multicolumn{1}{r}{18.51 / 0.546 / 0.119} & \\multicolumn{1}{r}{24.68 / 0.667 / 0.099} & \\multicolumn{1}{r}{20.98 / 0.745 / 0.074} & \\multicolumn{1}{r}{19.32 / 0.578 / 0.102} & \\multicolumn{1}{r|}{21.41 / 0.758 / 0.080} \\\\ \\hline\n", "\n", "['floating-tree', 'aspen', 'stump', 'sculpture', 'Giannini-Hall']\n", "no contraction & \\multicolumn{1}{r}{18.98 / 0.679 / 0.088} & \\multicolumn{1}{r}{15.80 / 0.330 / 0.342} & \\multicolumn{1}{r}{20.69 / 0.704 / 0.075} & \\multicolumn{1}{r}{21.43 / 0.720 / 0.073} & \\multicolumn{1}{r|}{17.75 / 0.596 / 0.134} \\\\ \n", "synthetic on real & \\multicolumn{1}{r}{21.13 / 0.726 / 0.072} & \\multicolumn{1}{r}{15.53 / 0.301 / 0.332} & \\multicolumn{1}{r}{23.86 / 0.786 / 0.053} & \\multicolumn{1}{r}{22.62 / 0.706 / 0.076} & \\multicolumn{1}{r|}{18.41 / 0.576 / 0.133} \\\\ \\hline\n" ] } ], "source": [ "capture_names_row1 = [\n", " \"Egypt\",\n", " \"person\",\n", " \"kitchen\",\n", " \"plane\",\n", " \"dozer\"\n", "]\n", "capture_names_row2 = [\n", " \"floating-tree\",\n", " \"aspen\",\n", " \"stump\",\n", " \"sculpture\",\n", " \"Giannini-Hall\"\n", "]\n", "\n", "print(capture_names_row1)\n", "for method in methods[:-1]:\n", " # print(generate_row(method, capture_names_row1) + ' \\\\\\ \\cline{1-1}')\n", " print(generate_row(method, capture_names_row1) + ' \\\\\\ ')\n", "print(generate_row(methods[-1], capture_names_row1) + ' \\\\\\ \\hline')\n", "\n", "print()\n", "\n", "print(capture_names_row2)\n", "for method in methods[:-1]:\n", " # print(generate_row(method, capture_names_row2) + ' \\\\\\ \\cline{1-1}')\n", " print(generate_row(method, capture_names_row2) + ' \\\\\\ ')\n", "print(generate_row(methods[-1], capture_names_row2) + ' \\\\\\ \\hline')\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "nerfactory", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.6" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "b7b86c17c0dfd6b313529972d424f2e075cc198a46cda005757126afe8133c7b" } } }, "nbformat": 4, "nbformat_minor": 2 }