Created
February 18, 2019 00:06
-
-
Save SeijiEmery/f48ea34867834e7cfadf25924f8ab296 to your computer and use it in GitHub Desktop.
concept code for rewriting shapenet utils
This file contains hidden or 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
from utils.jobs import * | |
@job("apply-subdivision") | |
class BpySubdivisionJob (BpyJob): | |
@describe('input', type='file', ext='.obj') | |
@describe('output', type='file', ext='.obj') | |
@describe('subdivisions', type=intrange(1,6)) | |
def run (self, input, output, subdivisions = 2): | |
src_obj = self.load_obj(path=input) | |
cube = self.create_cube() | |
self.apply_subsurf_modifer(cube, | |
levels=subdivisions, render_levels=subdivisions) | |
self.apply_shrinkwrap_modifier(cube, | |
target=src_obj) | |
self.export_obj(cube, path=output) | |
if __name__ == '__main__': | |
BpySubdivisionJob.run_with_sys_args() | |
import os | |
@job("load-taxonomy") | |
class LocateTaxonomy (FileIOJob): | |
@describe('input', type='directory') | |
@describe('output', type='file', ext='.json') | |
def run (self, input, output): | |
pass | |
@job("find-synsets") | |
class SynsetQuery (FileIOJob): | |
@describe('input', type='string') | |
@describe('output', type='list') | |
@describe('taxonomy_path', job='load-taxonomy') | |
def run (self, input, output, taxonomy_path): | |
pass | |
@job("build-file-index") | |
class BuildFileIndexJob (FileIOJob): | |
@describe('input', type='directory') | |
@describe('output', type='dict', file='file-index.pkl') | |
def run (self, input, output): | |
output['dirs'] = output['dirs'] or {} | |
output['files'] = output['files'] or {} | |
for file in os.walk | |
... | |
@job("find-shapenet-models") | |
class FindShapenetModels (FileIOJob): | |
@describe('input', job='build-file-index') | |
@describe('output', type='list') | |
def run (self, input, output): | |
pass | |
@job("find-obj") | |
class FindObj (FileIOJob): | |
@describe('input', type='directory') | |
@describe('output', type='file', ext='.obj') | |
def run (self, input, output): | |
pass | |
@job("extract-shapenet-params") | |
class ExtractShapenetParams (Job): | |
@describe('input', job='apply-subdivision') | |
@describe('output', type='dict', ext='.pkl') | |
def run (self, input, output): | |
pass | |
@job("collate-shapenet-params") | |
class CollateShapenetParams (MergeJob): | |
@describe('inputs', jobs='extract-shapenet-params') | |
@describe('output', type='file', ext='.json|.json.zip|.pkl') | |
def run (self, inputs, output): | |
return { | |
params['path']: params | |
for params in inputs | |
} | |
@job("process-models") | |
class ProcessModels (Job): | |
@describe('input', type='directory') | |
@describe('output', type='file') | |
@describe('query', type='string', default='') | |
@describe('subdivisions', type=intrange(1,6), default=2) | |
def run (self, input, output): | |
shapenet_dir = self.exec("locate-shapenet-dir", | |
input=input) | |
synsets = self.exec("find-synsets", | |
input=self.exec("locate-taxonomy", shapenet_dir), | |
query=query) | |
models = self.exec("find-matching-models", | |
input=shapenet_dir, | |
synsets=synsets) | |
datasets = self.map(models, "process-model-via-subdivision", | |
subdivisions=subdivisions) | |
data = { | |
params['path']: params | |
for params in datasets | |
} | |
self.save(data, path=output) | |
if __name__ == '__main__': | |
ProcessModels.run_with_sys_args() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment