From dcb4e9316f57be9e78b412b1190ff8244551c105 Mon Sep 17 00:00:00 2001 From: eaidova Date: Fri, 13 Sep 2024 08:34:30 +0400 Subject: [PATCH 1/2] fix passing optional args in triposr wrappers --- .../triposr-3d-reconstruction.ipynb | 105 +++++++++++++++--- 1 file changed, 88 insertions(+), 17 deletions(-) diff --git a/notebooks/triposr-3d-reconstruction/triposr-3d-reconstruction.ipynb b/notebooks/triposr-3d-reconstruction/triposr-3d-reconstruction.ipynb index cf1d6a8e490..43ee540518f 100644 --- a/notebooks/triposr-3d-reconstruction/triposr-3d-reconstruction.ipynb +++ b/notebooks/triposr-3d-reconstruction/triposr-3d-reconstruction.ipynb @@ -84,7 +84,21 @@ "execution_count": 2, "id": "b78424b7-80e4-4470-9427-7286b9837566", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Cloning into 'TripoSR'...\n", + "remote: Enumerating objects: 120, done.\u001b[K\n", + "remote: Counting objects: 100% (116/116), done.\u001b[K\n", + "remote: Compressing objects: 100% (114/114), done.\u001b[K\n", + "remote: Total 120 (delta 38), reused 0 (delta 0), pack-reused 4 (from 1)\u001b[K\n", + "Receiving objects: 100% (120/120), 570.19 KiB | 1.07 MiB/s, done.\n", + "Resolving deltas: 100% (38/38), done.\n" + ] + } + ], "source": [ "import sys\n", "from pathlib import Path\n", @@ -122,7 +136,7 @@ " weight_name=\"model.ckpt\",\n", ")\n", "model.renderer.set_chunk_size(131072)\n", - "model.to(\"cpu\")" + "model.to(\"cpu\");" ] }, { @@ -181,10 +195,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "d9456c3c-64dd-4109-968c-8f51d42b9876", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/ea/work/py311/lib/python3.11/site-packages/transformers/models/vit/modeling_vit.py:163: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n", + " if num_channels != self.num_channels:\n" + ] + } + ], "source": [ "VIT_PATCH_EMBEDDINGS_OV_PATH = Path(\"models/vit_patch_embeddings_ir.xml\")\n", "\n", @@ -194,8 +217,8 @@ " super().__init__()\n", " self.patch_embeddings = patch_embeddings\n", "\n", - " def forward(self, pixel_values, interpolate_pos_encoding=True):\n", - " outputs = self.patch_embeddings(pixel_values=pixel_values, interpolate_pos_encoding=True)\n", + " def forward(self, pixel_values):\n", + " outputs = self.patch_embeddings(pixel_values=pixel_values)\n", " return outputs\n", "\n", "\n", @@ -227,11 +250,7 @@ "\n", " def forward(\n", " self,\n", - " hidden_states=None,\n", - " head_mask=None,\n", - " output_attentions=False,\n", - " output_hidden_states=False,\n", - " return_dict=False,\n", + " hidden_states,\n", " ):\n", " outputs = self.encoder(\n", " hidden_states=hidden_states,\n", @@ -336,7 +355,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "7986388de70945238d4407af5c60c348", + "model_id": "03ad2a182a8b4218b2fa7e8eef4b05e3", "version_major": 2, "version_minor": 0 }, @@ -522,7 +541,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "id": "28d8a250", "metadata": {}, "outputs": [], @@ -571,7 +590,29 @@ "execution_count": null, "id": "044bc9cf-3141-433d-a267-f5da84c9aa11", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Running on local URL: http://127.0.0.1:7860\n", + "\n", + "To create a public link, set `share=True` in `launch()`.\n" + ] + }, + { + "data": { + "text/html": [ + "
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "if not Path(\"gradio_helper.py\").exists():\n", " r = requests.get(url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/notebooks/triposr-3d-reconstruction/gradio_helper.py\")\n", @@ -604,7 +645,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -618,7 +659,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.8" + "version": "3.11.4" }, "openvino_notebooks": { "imageUrl": "https://github.com/VAST-AI-Research/TripoSR/blob/main/figures/teaser800.gif?raw=true", @@ -636,7 +677,37 @@ }, "widgets": { "application/vnd.jupyter.widget-state+json": { - "state": {}, + "state": { + "03ad2a182a8b4218b2fa7e8eef4b05e3": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "2.0.0", + "model_name": "DropdownModel", + "state": { + "_options_labels": [ + "CPU", + "AUTO" + ], + "description": "Device:", + "index": 1, + "layout": "IPY_MODEL_bb09961cb666451db20c97f3f60c754d", + "style": "IPY_MODEL_f18bfec390354c1ababfb79126e39789" + } + }, + "bb09961cb666451db20c97f3f60c754d": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "2.0.0", + "model_name": "LayoutModel", + "state": {} + }, + "f18bfec390354c1ababfb79126e39789": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "2.0.0", + "model_name": "DescriptionStyleModel", + "state": { + "description_width": "" + } + } + }, "version_major": 2, "version_minor": 0 } From d1c09739c09a8a6a52cde6f983a3cc0c096b1448 Mon Sep 17 00:00:00 2001 From: eaidova Date: Fri, 13 Sep 2024 10:14:46 +0400 Subject: [PATCH 2/2] fix example input --- .../triposr-3d-reconstruction/triposr-3d-reconstruction.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebooks/triposr-3d-reconstruction/triposr-3d-reconstruction.ipynb b/notebooks/triposr-3d-reconstruction/triposr-3d-reconstruction.ipynb index 43ee540518f..90134579740 100644 --- a/notebooks/triposr-3d-reconstruction/triposr-3d-reconstruction.ipynb +++ b/notebooks/triposr-3d-reconstruction/triposr-3d-reconstruction.ipynb @@ -223,7 +223,7 @@ "\n", "\n", "example_input = {\n", - " \"pixel_values\": torch.rand([1, 3, 512, 512], dtype=torch.float32),\n", + " \"pixel_values\": torch.rand([1, 3, 224, 224], dtype=torch.float32),\n", "}\n", "\n", "convert(\n",