Files changed (12)
- .gitattributes+1
- apps/__pycache__/mv_models.cpython-38.pyc
- apps/__pycache__/utils.cpython-38.pyc
- apps/gradio_app.py+10-3
- apps/mv_models.py+38-7
- apps/third_party/CRM/imagedream/ldm/util.py+2-2
- apps/third_party/CRM/libs/sample.py+1-1
- apps/third_party/InstantMeshes
- apps/third_party/Wonder3D/mvdiffusion/data/single_image_dataset.py+1-1
- apps/utils.py+3-2
- gradio_app.py+14-9
- requirements.txt+1-1
37 unmodified lines38394037 unmodified linesasset/video_cover.png filter=lfs diff=lfs merge=lfs -textapps/InstantMeshes filter=lfs diff=lfs merge=lfs -textapps/third_party/InstantMeshes filter=lfs diff=lfs merge=lfs -text37 unmodified lines3839404137 unmodified linesasset/video_cover.png filter=lfs diff=lfs merge=lfs -textapps/InstantMeshes filter=lfs diff=lfs merge=lfs -textapps/third_party/InstantMeshes filter=lfs diff=lfs merge=lfs -textapps/third_party/quadriflow filter=lfs diff=lfs merge=lfs -text
19 unmodified lines20212223242578 unmodified lines10410510610710810911011111211311411511611711811919 unmodified linesproj_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))sys.path.append(os.path.join(proj_dir))import craftsmanfrom craftsman.systems.base import BaseSystemfrom craftsman.utils.config import ExperimentConfig, load_config78 unmodified lines)assert len(mesh_outputs) == 1, "Only support single mesh output for gradio demo"mesh = trimesh.Trimesh(mesh_outputs[0][0], mesh_outputs[0][1])filepath = f"{cached_dir}/{time.time()}.obj"mesh.export(filepath, include_normals=True)if 'Remesh' in more:print("Remeshing with Instant Meshes...")target_face_count = int(len(mesh.faces)/10)# command = f"{proj_dir}/apps/third_party/InstantMeshes {filepath} -f {target_face_count} -d -S 0 -r 6 -p 6 -o {filepath.replace('.obj', '_remeshed.obj')}"command = f"{proj_dir}/apps/third_party/InstantMeshes {filepath} -f {target_face_count} -d -S 0 -r 4 -p 4 -o {filepath.replace('.obj', '_remeshed.obj')}"os.system(command)filepath = filepath.replace('.obj', '_remeshed.obj')return filepath19 unmodified lines202122232425262778 unmodified lines10610710810911011111211311411511611711811912012112212312412512619 unmodified linesproj_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))sys.path.append(os.path.join(proj_dir))import tempfileimport craftsmanfrom craftsman.systems.base import BaseSystemfrom craftsman.utils.config import ExperimentConfig, load_config78 unmodified lines)assert len(mesh_outputs) == 1, "Only support single mesh output for gradio demo"mesh = trimesh.Trimesh(mesh_outputs[0][0], mesh_outputs[0][1])# filepath = f"{cached_dir}/{time.time()}.obj"filepath = tempfile.NamedTemporaryFile(suffix=f".obj", delete=False).namemesh.export(filepath, include_normals=True)if 'Remesh' in more:remeshed_filepath = tempfile.NamedTemporaryFile(suffix=f"_remeshed.obj", delete=False).nameprint("Remeshing with Instant Meshes...")target_face_count = int(len(mesh.faces)/10)# command = f"{proj_dir}/apps/third_party/InstantMeshes {filepath} -f {target_face_count} -d -S 0 -r 6 -p 6 -o {filepath.replace('.obj', '_remeshed.obj')}"# command = f"{proj_dir}/apps/third_party/InstantMeshes {filepath} -f {target_face_count} -d -S 0 -r 4 -p 4 -o {filepath.replace('.obj', '_remeshed.obj')}"# command = f"{proj_dir}/apps/third_party/InstantMeshes {filepath} -f {target_face_count} -o {filepath.replace('.obj', '_remeshed.obj')}"command = f"{proj_dir}/apps/third_party/quadriflow -i {filepath} -f {target_face_count} -o {remeshed_filepath}"os.system(command)filepath = remeshed_filepath# filepath = filepath.replace('.obj', '_remeshed.obj')return filepath
18 unmodified lines19202122232471 unmodified lines9697989910010110210310410510610710810911011111211311418 unmodified linesparent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))class GenMVImage(object):def __init__(self, device):self.seed = 102471 unmodified linesreturn mv_imgs[1], mv_imgs[2], mv_imgs[3], mv_imgs[0]def gen_image_from_wonder3d(self, image, crop_size):sys.path.append(f"{parent_dir}/apps/third_party/Wonder3D")from .third_party.Wonder3D.mvdiffusion.pipelines.pipeline_mvdiffusion_image import MVDiffusionImagePipelineweight_dtype = torch.float16batch = prepare_data(image, crop_size)if "wonder3d" in self.pipelines.keys():pipeline = self.pipelines['wonder3d']else:self.pipelines['wonder3d'] = MVDiffusionImagePipeline.from_pretrained('flamehaze1115/wonder3d-v1.0',custom_pipeline=f'{parent_dir}/apps/third_party/Wonder3D/mvdiffusion/pipelines/pipeline_mvdiffusion_image.py',torch_dtype=weight_dtype)self.pipelines['wonder3d'].unet.enable_xformers_memory_efficient_attention()self.pipelines['wonder3d'].to(self.device)self.pipelines['wonder3d'].set_progress_bar_config(disable=True)18 unmodified lines1920212223242526272829303132333435363738394041424344454647484950515253545571 unmodified lines12712812913013113213313413513613713813914014114214314414518 unmodified linesparent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))@dataclassclass TestConfig:pretrained_model_name_or_path: strpretrained_unet_path: strrevision: Optional[str]validation_dataset: Dictsave_dir: strseed: Optional[int]validation_batch_size: intdataloader_num_workers: intlocal_rank: intpipe_kwargs: Dictpipe_validation_kwargs: Dictunet_from_pretrained_kwargs: Dictvalidation_guidance_scales: List[float]validation_grid_nrow: intcamera_embedding_lr_mult: floatnum_views: intcamera_embedding_type: strpred_type: str # joint, or ablationenable_xformers_memory_efficient_attention: boolcond_on_normals: boolcond_on_colors: boolclass GenMVImage(object):def __init__(self, device):self.seed = 102471 unmodified linesreturn mv_imgs[1], mv_imgs[2], mv_imgs[3], mv_imgs[0]def gen_image_from_wonder3d(self, image, crop_size):from diffusers import DiffusionPipeline # only tested on diffusers[torch]==0.19.3, may have conflicts with newer versions of diffusersweight_dtype = torch.float16batch = prepare_data(image, crop_size)if "wonder3d" in self.pipelines.keys():pipeline = self.pipelines['wonder3d']else:self.pipelines['wonder3d'] = DiffusionPipeline.from_pretrained('flamehaze1115/wonder3d-v1.0', # or use local checkpoint './ckpts'custom_pipeline='flamehaze1115/wonder3d-pipeline',torch_dtype=torch.float16)self.pipelines['wonder3d'].unet.enable_xformers_memory_efficient_attention()self.pipelines['wonder3d'].to(self.device)self.pipelines['wonder3d'].set_progress_bar_config(disable=True)
94 unmodified lines959697989910010110210394 unmodified linesimportlib.reload(module_imp)if 'imagedream' in module:module = 'third_party.CRM.'+moduleif 'lib' in module:module = 'third_party.CRM.'+modulereturn getattr(importlib.import_module(module, package=None), cls)94 unmodified lines959697989910010110210394 unmodified linesimportlib.reload(module_imp)if 'imagedream' in module:module = 'apps.third_party.CRM.'+moduleif 'lib' in module:module = 'apps.third_party.CRM.'+modulereturn getattr(importlib.import_module(module, package=None), cls)
5 unmodified lines67891011125 unmodified lines# import sys# proj_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))# sys.path.append(proj_dir)from third_party.CRM.libs.base_utils import do_resize_contentfrom imagedream.ldm.models.diffusion.ddim import DDIMSamplerfrom torchvision import transforms as T5 unmodified lines67891011125 unmodified lines# import sys# proj_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))# sys.path.append(proj_dir)from apps.third_party.CRM.libs.base_utils import do_resize_contentfrom imagedream.ldm.models.diffusion.ddim import DDIMSamplerfrom torchvision import transforms as T
106 unmodified lines107108109110111112113106 unmodified lineselif self.num_views == 6:self.view_types = ['front', 'front_right', 'right', 'back', 'left', 'front_left']self.fix_cam_pose_dir = "./third_party/Wonder3D/mvdiffusion/data/fixed_poses/nine_views"self.fix_cam_poses = self.load_fixed_poses() # world2cam matrix106 unmodified lines107108109110111112113106 unmodified lineselif self.num_views == 6:self.view_types = ['front', 'front_right', 'right', 'back', 'left', 'front_left']self.fix_cam_pose_dir = "apps/third_party/Wonder3D/mvdiffusion/data/fixed_poses/nine_views"self.fix_cam_poses = self.load_fixed_poses() # world2cam matrix
16 unmodified lines17181920212224 unmodified lines4748495051525381 unmodified lines13513613713813914014116 unmodified linesfrom segment_anything import sam_model_registry, SamPredictorimport craftsmanfrom craftsman.utils.config import ExperimentConfig, load_configparent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))24 unmodified lines)print(f"Restoring states from the checkpoint path at {ckpt_path} with config {cfg}")system.load_state_dict(torch.load(ckpt_path)['state_dict'])system = system.to(device).eval()return system81 unmodified linesreturn ndarrdef prepare_data(single_image, crop_size):from third_party.Wonder3D.mvdiffusion.data.single_image_dataset import SingleImageDatasetdataset = SingleImageDataset(root_dir='', num_views=6, img_wh=[256, 256], bg_color='white', crop_size=crop_size, single_image=single_image)return dataset[0]16 unmodified lines1718192021222324 unmodified lines4849505152535481 unmodified lines13613713813914014114216 unmodified linesfrom segment_anything import sam_model_registry, SamPredictorimport craftsmanfrom craftsman.systems.base import BaseSystemfrom craftsman.utils.config import ExperimentConfig, load_configparent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))24 unmodified lines)print(f"Restoring states from the checkpoint path at {ckpt_path} with config {cfg}")system.load_state_dict(torch.load(ckpt_path, map_location=torch.device('cpu'))['state_dict'])system = system.to(device).eval()return system81 unmodified linesreturn ndarrdef prepare_data(single_image, crop_size):from apps.third_party.Wonder3D.mvdiffusion.data.single_image_dataset import SingleImageDatasetdataset = SingleImageDataset(root_dir='', num_views=6, img_wh=[256, 256], bg_color='white', crop_size=crop_size, single_image=single_image)return dataset[0]
18 unmodified lines19202122232479 unmodified lines10410510610710810911011111211311411511611711811912012179 unmodified lines20120220320420520620720820921018 unmodified linesproj_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))sys.path.append(os.path.join(proj_dir))import craftsmanfrom craftsman.systems.base import BaseSystemfrom craftsman.utils.config import ExperimentConfig, load_config79 unmodified lines)assert len(mesh_outputs) == 1, "Only support single mesh output for gradio demo"mesh = trimesh.Trimesh(mesh_outputs[0][0], mesh_outputs[0][1])filepath = f"{cached_dir}/{time.time()}.obj"mesh.export(filepath, include_normals=True)if 'Remesh' in more:print("Remeshing with Instant Meshes...")target_face_count = int(len(mesh.faces)/10)command = f"{proj_dir}/apps/third_party/InstantMeshes {filepath} -f {target_face_count} -d -S 0 -r 6 -p 6 -o {filepath.replace('.obj', '_remeshed.obj')}"os.system(command)filepath = filepath.replace('.obj', '_remeshed.obj')return filepathif __name__=="__main__":parser = argparse.ArgumentParser()# parser.add_argument("--model_path", type=str, required=True, help="Path to the object file",)79 unmodified linesview_back = gr.Image(label="Back", interactive=True, show_label=True)view_left = gr.Image(label="Left", interactive=True, show_label=True)with gr.Accordion('Advanced options', open=False):with gr.Row(equal_height=True):run_mv_btn = gr.Button('Only Generate 2D', interactive=True)run_3d_btn = gr.Button('Only Generate 3D', interactive=True)with gr.Accordion('Advanced options (2D)', open=False):with gr.Row():18 unmodified lines1920212223242579 unmodified lines10510610710810911011111211311411511611711811912012112212312412512679 unmodified lines20620720820921021121221321421518 unmodified linesproj_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))sys.path.append(os.path.join(proj_dir))import tempfileimport craftsmanfrom craftsman.systems.base import BaseSystemfrom craftsman.utils.config import ExperimentConfig, load_config79 unmodified lines)assert len(mesh_outputs) == 1, "Only support single mesh output for gradio demo"mesh = trimesh.Trimesh(mesh_outputs[0][0], mesh_outputs[0][1])# filepath = f"{cached_dir}/{time.time()}.obj"filepath = tempfile.NamedTemporaryFile(suffix=f".obj", delete=False).namemesh.export(filepath, include_normals=True)if 'Remesh' in more:remeshed_filepath = tempfile.NamedTemporaryFile(suffix=f"_remeshed.obj", delete=False).nameprint("Remeshing with Instant Meshes...")# target_face_count = int(len(mesh.faces)/10)target_face_count = 1000command = f"{proj_dir}/apps/third_party/InstantMeshes {filepath} -f {target_face_count} -o {remeshed_filepath}"os.system(command)filepath = remeshed_filepath# filepath = filepath.replace('.obj', '_remeshed.obj')return filepathif __name__=="__main__":parser = argparse.ArgumentParser()# parser.add_argument("--model_path", type=str, required=True, help="Path to the object file",)79 unmodified linesview_back = gr.Image(label="Back", interactive=True, show_label=True)view_left = gr.Image(label="Left", interactive=True, show_label=True)# with gr.Accordion('Advanced options', open=False):with gr.Row(equal_height=True):run_mv_btn = gr.Button('Only Generate 2D', interactive=True)run_3d_btn = gr.Button('Only Generate 3D', interactive=True)with gr.Accordion('Advanced options (2D)', open=False):with gr.Row():
12345datasets==2.19.0diffusers==0.27.2einops==0.8.0huggingface-hub==0.22.2imageio==2.34.112345datasets==2.19.0diffusers==0.19.3einops==0.8.0huggingface-hub==0.22.2imageio==2.34.1
.gitattributes+1
apps/__pycache__/mv_models.cpython-38.pyc
apps/__pycache__/utils.cpython-38.pyc
apps/gradio_app.py+10-3
apps/mv_models.py+38-7
apps/third_party/CRM/imagedream/ldm/util.py+2-2
apps/third_party/CRM/libs/sample.py+1-1
apps/third_party/InstantMeshes
apps/third_party/Wonder3D/mvdiffusion/data/single_image_dataset.py+1-1
apps/utils.py+3-2
gradio_app.py+14-9
requirements.txt+1-1