wyysf commited on
Commit
0343e3c
·
1 Parent(s): 9505fe5
Files changed (4) hide show
  1. ckpts/.gitattributes +0 -35
  2. ckpts/README.md +0 -117
  3. ckpts/craftsman-v1-5 +0 -1
  4. server.py +0 -98
ckpts/.gitattributes DELETED
@@ -1,35 +0,0 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ckpts/README.md DELETED
@@ -1,117 +0,0 @@
1
- ---
2
- library_name: craftsman-v1-5
3
- license: creativeml-openrail-m
4
- license_name: creativeml-openrail-m
5
- license_link: https://raw.githubusercontent.com/CompVis/stable-diffusion/refs/heads/main/LICENSE
6
- pipeline_tag: image-to-3d
7
- language:
8
- - en
9
- - zh
10
- ---
11
-
12
- ## **CraftsMan-v1-5**
13
-
14
- <p align="center">
15
- <img src="./assets/teaser.png" height=200>
16
- </p>
17
-
18
- ### <div align="center">CraftsMan: High-fidelity Mesh Generation <br> with 3D Native Generation and Interactive Geometry Refiner<div>
19
- ##### <p align="center"> [Weiyu Li<sup>*1,2</sup>](https://wyysf-98.github.io/), Jiarui Liu<sup>*1,2</sup>, Hongyu Yan<sup>*1,2</sup>, [Rui Chen<sup>1,2</sup>](https://aruichen.github.io/), [Yixun Liang<sup>2,3</sup>](https://yixunliang.github.io/), [Xuelin Chen<sup>4</sup>](https://xuelin-chen.github.io/), [Ping Tan<sup>1,2</sup>](https://ece.hkust.edu.hk/pingtan), [Xiaoxiao Long<sup>1,2</sup>](https://www.xxlong.site/)</p>
20
- ##### <p align="center"> <sup>1</sup>HKUST, <sup>2</sup>LightIllusions, <sup>3</sup>HKUST(GZ), <sup>4</sup>Tencent AI Lab</p>
21
- <div align="center">
22
- <a href="https://craftsman3d.github.io/"><img src="https://img.shields.io/static/v1?label=Project%20Page&message=Github&color=blue&logo=github-pages"></a> &ensp;
23
- <a href="http://algodemo.bj.lightions.top:24926"><img src="https://www.gradio.app/_app/immutable/assets/gradio.CHB5adID.svg" height="25"/></a> &ensp;
24
- <a href="https://arxiv.org/pdf/2405.14979"><img src="https://img.shields.io/static/v1?label=Paper&message=Arxiv&color=red&logo=arxiv"></a> &ensp;
25
- </div>
26
-
27
- # Usage
28
-
29
- To use the model, please refer to the [official repository](https://github.com/wyysf-98/CraftsMan) for installation and usage instructions.
30
-
31
- ```
32
-
33
- from craftsman import CraftsManPipeline
34
- import torch
35
-
36
- pipeline = CraftsManPipeline.from_pretrained("./ckpts/craftsman-v1-5", device="cuda:0", torch_dtype=torch.float32) # load from local ckpt
37
- mesh = pipeline("https://pub-f9073a756ec645d692ce3d171c2e1232.r2.dev/data/werewolf.png").meshes[0]
38
- mesh.export("werewolf.obj")
39
-
40
- ```
41
-
42
- ## 🔥🔥🔥 News!!
43
-
44
- * Nov 16, 2024: 💬 We release the CraftsMan-v1-5
45
-
46
-
47
- ## 📑 Open-source Plan
48
-
49
- - [x] Inference
50
- - [x] Checkpoints
51
- - [x] Training
52
- - [ ] ComfyUI
53
-
54
- ## 🎉 **CraftMan-v1-5 Architecture**
55
-
56
- <p align="center">
57
- <img src="./assets/arch.png" height=400>
58
- </p>
59
-
60
-
61
- ## Get Started
62
-
63
- #### Begin by cloning the repository:
64
-
65
- ```shell
66
- git clone https://github.com/wyysf-98/CraftsMan
67
- cd CraftsMan
68
- ```
69
-
70
- #### Installation Guide for Linux
71
-
72
- We provide an env_install.sh script file for setting up environment.
73
-
74
- ```
75
- # step 1, create conda env
76
- conda create -n CraftsMan python=3.10
77
- conda activate CraftsMan
78
-
79
-
80
- # step 2. install torch realated package
81
- conda install -c pytorch pytorch=2.3.0 torchvision=0.18.0 cudatoolkit=11.8
82
-
83
- # step 3. install other packages
84
- pip install -r docker/requirements.txt
85
- ```
86
- <details>
87
-
88
-
89
- #### Using Gradio
90
-
91
- We have prepared a gradio demo for you to try out the model. You can run the following command to start the demo.
92
-
93
- ```shell
94
- # std
95
- python3 gradio.py
96
- ```
97
-
98
- Then the demo can be accessed through the output link.
99
-
100
-
101
- ## Citation
102
-
103
- If you found this repository helpful, please cite our report:
104
- ```bibtex
105
- @misc{li2024craftsman,
106
- title = {CraftsMan: High-fidelity Mesh Generation with 3D Native Generation and Interactive Geometry Refiner},
107
- author = {Weiyu Li and Jiarui Liu and Rui Chen and Yixun Liang and Xuelin Chen and Ping Tan and Xiaoxiao Long},
108
- year = {2024},
109
- archivePrefix = {arXiv preprint arXiv:2405.14979},
110
- primaryClass = {cs.CG}
111
- }
112
- ```
113
-
114
-
115
- # License
116
-
117
- [creativeml-openrail-m](https://raw.githubusercontent.com/CompVis/stable-diffusion/refs/heads/main/LICENSE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ckpts/craftsman-v1-5 DELETED
@@ -1 +0,0 @@
1
- Subproject commit 9a5e9189c2dfab20cf838885dd6acaf99b41844e
 
 
server.py DELETED
@@ -1,98 +0,0 @@
1
- import argparse
2
- import base64
3
- import os
4
- from datetime import datetime
5
- import traceback
6
- import torch
7
- import trimesh
8
- from craftsman import CraftsManPipeline
9
-
10
- CURRENT_DIR = f'/tmp/native3d_server/{os.getpid()}'
11
- os.makedirs(CURRENT_DIR, exist_ok=True)
12
-
13
- def parse_parameters():
14
- parser = argparse.ArgumentParser("native3d")
15
- parser.add_argument('--host', default="0.0.0.0", type=str)
16
- parser.add_argument('--port', default=80, type=int)
17
- return parser.parse_args()
18
-
19
- # -------------------- fastapi --------------------
20
- from typing import Optional
21
- from pydantic import BaseModel, Field
22
-
23
- class Native3DRequestV1(BaseModel):
24
- image_path: str # input image path
25
- mesh_path: str # output mesh path, support glb or obj in clean dir
26
-
27
- class Native3DResponseV1(BaseModel):
28
- pass
29
-
30
- class Native3DRequestV2(BaseModel):
31
- image_bytes: str # input image bytes(base64)
32
- mesh_type: str # output mesh type, support glb or obj
33
-
34
- class Native3DResponseV2(BaseModel):
35
- mesh_bytes: str # output mesh bytes(base64)
36
-
37
- if __name__=="__main__":
38
- parse_args = parse_parameters()
39
-
40
- # prepare models
41
- pipeline = CraftsManPipeline.from_pretrained("ckpts/craftsman-v1-5", device="cuda:0", torch_dtype=torch.float32)
42
-
43
- # -------------------- fastapi --------------------
44
- from fastapi import FastAPI, Request
45
- import requests
46
- app = FastAPI()
47
-
48
- @app.post("/native3d_v1", response_model=Native3DResponseV1)
49
- async def native3d(request: Request, image_to_mesh_request: Native3DRequestV1):
50
- try:
51
- print(f"image_to_mesh_request = {image_to_mesh_request}")
52
- mesh = pipeline(image_to_mesh_request.image_path).meshes[0]
53
- os.makedirs(os.path.dirname(os.path.abspath(image_to_mesh_request.mesh_path)), exist_ok=True)
54
- mesh.export(image_to_mesh_request.mesh_path)
55
- except Exception as e:
56
- traceback.print_exc()
57
- print(f"generate_model error: {e}")
58
- return Native3DResponseV1()
59
-
60
- @app.post("/native3d_v2", response_model=Native3DResponseV2)
61
- async def native3d(request: Request, image_to_mesh_request: Native3DRequestV2):
62
- try:
63
- # print(f"image_to_mesh_request = {image_to_mesh_request}")
64
- mesh_type = image_to_mesh_request.mesh_type
65
- assert mesh_type in ['obj', 'glb']
66
- task_id = datetime.now().strftime('%Y-%m-%d-%H-%M-%S-%f') + '-' + 'native3d'
67
- current_dir = os.path.join(CURRENT_DIR, task_id)
68
- os.makedirs(current_dir, exist_ok=True)
69
- image_path = os.path.join(current_dir, 'input_image.png')
70
- with open(image_path, 'wb') as f:
71
- f.write(base64.b64decode(image_to_mesh_request.image_bytes))
72
- mesh_path = os.path.join(current_dir, f'output_mesh.{mesh_type}')
73
- import time
74
- start = time.time()
75
- # mesh = pipeline(image_path, mc_depth=8, num_inference_steps=25).meshes[0]
76
- # mesh = pipeline(image_path, mc_depth=7, num_inference_steps=25).meshes[0]
77
- mesh = pipeline(image_path, mc_depth=7, num_inference_steps=50).meshes[0]
78
- print(f"Time: {time.time() - start}s")
79
- os.makedirs(os.path.dirname(os.path.abspath(mesh_path)), exist_ok=True)
80
- mesh.visual = trimesh.visual.TextureVisuals(
81
- material=trimesh.visual.material.PBRMaterial(
82
- baseColorFactor=(255, 255, 255), main_color=(255, 255, 255), metallicFactor=0.05, roughnessFactor=1.0
83
- )
84
- )
85
- mesh.export(mesh_path)
86
- with open(mesh_path, 'rb') as f:
87
- mesh_bytes = f.read()
88
- except Exception as e:
89
- traceback.print_exc()
90
- print(f"generate_model error: {e}")
91
- return Native3DResponseV2(mesh_bytes=base64.b64encode(mesh_bytes).decode('utf-8'))
92
-
93
- @app.get("/health")
94
- async def health():
95
- return {"status": "OK"}
96
-
97
- import uvicorn
98
- uvicorn.run(app, host=parse_args.host, port=parse_args.port)