Skip to content

Commit

Permalink
fix passing optional args in triposr wrappers (#2389)
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova authored Sep 13, 2024
1 parent 57a758c commit 8677d84
Showing 1 changed file with 89 additions and 18 deletions.
107 changes: 89 additions & 18 deletions notebooks/triposr-3d-reconstruction/triposr-3d-reconstruction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -122,7 +136,7 @@
" weight_name=\"model.ckpt\",\n",
")\n",
"model.renderer.set_chunk_size(131072)\n",
"model.to(\"cpu\")"
"model.to(\"cpu\");"
]
},
{
Expand Down Expand Up @@ -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",
Expand All @@ -194,13 +217,13 @@
" 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",
"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",
Expand All @@ -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",
Expand Down Expand Up @@ -336,7 +355,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7986388de70945238d4407af5c60c348",
"model_id": "03ad2a182a8b4218b2fa7e8eef4b05e3",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -522,7 +541,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"id": "28d8a250",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -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": [
"<div><iframe src=\"http://127.0.0.1:7860/\" width=\"100%\" height=\"680\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"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",
Expand Down Expand Up @@ -604,7 +645,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -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",
Expand All @@ -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
}
Expand Down

0 comments on commit 8677d84

Please sign in to comment.