-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexey Bokhovkin
committed
Mar 4, 2019
1 parent
ec4fabb
commit 0a3f3ca
Showing
5 changed files
with
236 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
data/raw_data/ | ||
src/notebooks/.ipynb_checkpoints/ | ||
src/backend/__pycache__/ | ||
src/backend/datasets/__pycache__/ | ||
src/backend/sampler/__pycache__/ | ||
|
||
*.npy | ||
*.npz |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .sampler import MeshSampler |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,233 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 14, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import sys \n", | ||
"sys.path.append('..')\n", | ||
"import warnings\n", | ||
"warnings.filterwarnings('ignore')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from backend.sampler import MeshSampler\n", | ||
"import trimesh\n", | ||
"import numpy as np\n", | ||
"import os\n", | ||
"from tqdm import tqdm_notebook as tqdm" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"DATA_DIR = '../../../../data/ShapeNetCorev2/ShapeNetCore.v2/'\n", | ||
"SAVE_DIR = '../../data/processed_data/'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "9607c49b076d4181b9a4810eb29abba0", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"HBox(children=(IntProgress(value=0, max=56), HTML(value='')))" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "0483c2c4a3d64ffcb0f37520e2fec48e", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"HBox(children=(IntProgress(value=0, max=2373), HTML(value='')))" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "7024385d627849639910e0ae76821625", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"HBox(children=(IntProgress(value=0, max=71300), HTML(value='')))" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "ff22e66b581b49088807fc435405653f", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"HBox(children=(IntProgress(value=0, max=250000), HTML(value='')))" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "15a821d689bb4fb49628569c7a595f0a", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"HBox(children=(IntProgress(value=0, max=33250), HTML(value='')))" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "41c10ea4f80444b6adb94c065e54ddec", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"HBox(children=(IntProgress(value=0, max=250000), HTML(value='')))" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "7566250046804f7e84fd918e94959901", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"HBox(children=(IntProgress(value=0, max=5072), HTML(value='')))" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "bd99a243f14e48188eb0fecfa52fe4c5", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"HBox(children=(IntProgress(value=0, max=250000), HTML(value='')))" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "84e258df96dd44d4b7414651f7445bb5", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"HBox(children=(IntProgress(value=0, max=56326), HTML(value='')))" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "a4abfe096c5247eeaeabd30a94dd1773", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"HBox(children=(IntProgress(value=0, max=250000), HTML(value='')))" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"for synsetId in tqdm(os.listdir(DATA_DIR)):\n", | ||
" SYNSET_DIR = os.path.join(DATA_DIR, synsetId)\n", | ||
" for i, modelId in enumerate(tqdm(os.listdir(SYNSET_DIR))):\n", | ||
" if i == 5:\n", | ||
" break\n", | ||
" MODEL_DIR = os.path.join(SYNSET_DIR, modelId, 'models')\n", | ||
" MESH = os.path.join(MODEL_DIR, 'model_normalized.obj')\n", | ||
" \n", | ||
" sampler = MeshSampler(trimesh.load(MESH))\n", | ||
" sampler.compute_visible_faces()\n", | ||
" sampler.sample_points(n_points=250000)\n", | ||
" correct_mesh_points, correct_sdf = sampler.compute_sdf(sigma=0.0025)\n", | ||
" \n", | ||
" SAVE_PATH = os.path.join(SAVE_DIR, synsetId, modelId)\n", | ||
" os.makedirs(SAVE_PATH, exist_ok=True)\n", | ||
" np.save(os.path.join(SAVE_PATH, 'points.npy'), correct_mesh_points)\n", | ||
" np.save(os.path.join(SAVE_PATH, 'sdfs.npy'), correct_sdf)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"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.6.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |