Commit
·
cb29219
1
Parent(s):
8a76def
Refactor generate3d function in inference.py to enhance readability by removing unnecessary blank lines. Update requirements.txt to specify versions for gradio and huggingface-hub for better dependency management.
Browse files- inference.py +5 -1
- requirements.txt +2 -2
inference.py
CHANGED
@@ -7,8 +7,8 @@ import tempfile
|
|
7 |
from mesh import Mesh
|
8 |
import zipfile
|
9 |
from util.renderer import Renderer
|
10 |
-
|
11 |
def generate3d(model, rgb, ccm, device):
|
|
|
12 |
model.renderer = Renderer(tet_grid_size=model.tet_grid_size, camera_angle_num=model.camera_angle_num,
|
13 |
scale=model.input.scale, geo_type = model.geo_type)
|
14 |
|
@@ -17,6 +17,7 @@ def generate3d(model, rgb, ccm, device):
|
|
17 |
color = color_tri.permute(2,0,1)
|
18 |
xyz = xyz_tri.permute(2,0,1)
|
19 |
|
|
|
20 |
def get_imgs(color):
|
21 |
# color : [C, H, W*6]
|
22 |
color_list = []
|
@@ -37,6 +38,7 @@ def generate3d(model, rgb, ccm, device):
|
|
37 |
# 3D visualize
|
38 |
model.eval()
|
39 |
|
|
|
40 |
if model.denoising == True:
|
41 |
tnew = 20
|
42 |
tnew = torch.randint(tnew, tnew+1, [triplane.shape[0]], dtype=torch.long, device=triplane.device)
|
@@ -51,6 +53,7 @@ def generate3d(model, rgb, ccm, device):
|
|
51 |
else:
|
52 |
triplane_feature2 = model.unet2(triplane)
|
53 |
|
|
|
54 |
with torch.no_grad():
|
55 |
data_config = {
|
56 |
'resolution': [1024, 1024],
|
@@ -62,6 +65,7 @@ def generate3d(model, rgb, ccm, device):
|
|
62 |
data_config['verts'] = verts[0]
|
63 |
data_config['faces'] = faces
|
64 |
|
|
|
65 |
from kiui.mesh_utils import clean_mesh
|
66 |
verts, faces = clean_mesh(data_config['verts'].squeeze().cpu().numpy().astype(np.float32), data_config['faces'].squeeze().cpu().numpy().astype(np.int32), repair = False, remesh=True, remesh_size=0.005, remesh_iters=1)
|
67 |
data_config['verts'] = torch.from_numpy(verts).cuda().contiguous()
|
|
|
7 |
from mesh import Mesh
|
8 |
import zipfile
|
9 |
from util.renderer import Renderer
|
|
|
10 |
def generate3d(model, rgb, ccm, device):
|
11 |
+
|
12 |
model.renderer = Renderer(tet_grid_size=model.tet_grid_size, camera_angle_num=model.camera_angle_num,
|
13 |
scale=model.input.scale, geo_type = model.geo_type)
|
14 |
|
|
|
17 |
color = color_tri.permute(2,0,1)
|
18 |
xyz = xyz_tri.permute(2,0,1)
|
19 |
|
20 |
+
|
21 |
def get_imgs(color):
|
22 |
# color : [C, H, W*6]
|
23 |
color_list = []
|
|
|
38 |
# 3D visualize
|
39 |
model.eval()
|
40 |
|
41 |
+
|
42 |
if model.denoising == True:
|
43 |
tnew = 20
|
44 |
tnew = torch.randint(tnew, tnew+1, [triplane.shape[0]], dtype=torch.long, device=triplane.device)
|
|
|
53 |
else:
|
54 |
triplane_feature2 = model.unet2(triplane)
|
55 |
|
56 |
+
|
57 |
with torch.no_grad():
|
58 |
data_config = {
|
59 |
'resolution': [1024, 1024],
|
|
|
65 |
data_config['verts'] = verts[0]
|
66 |
data_config['faces'] = faces
|
67 |
|
68 |
+
|
69 |
from kiui.mesh_utils import clean_mesh
|
70 |
verts, faces = clean_mesh(data_config['verts'].squeeze().cpu().numpy().astype(np.float32), data_config['faces'].squeeze().cpu().numpy().astype(np.int32), repair = False, remesh=True, remesh_size=0.005, remesh_iters=1)
|
71 |
data_config['verts'] = torch.from_numpy(verts).cuda().contiguous()
|
requirements.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
gradio
|
2 |
-
huggingface-hub
|
3 |
diffusers==0.24.0
|
4 |
einops==0.7.0
|
5 |
Pillow==10.1.0
|
|
|
1 |
+
gradio==4.21.0
|
2 |
+
huggingface-hub==0.16.4
|
3 |
diffusers==0.24.0
|
4 |
einops==0.7.0
|
5 |
Pillow==10.1.0
|