-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
executable file
·54 lines (41 loc) · 1.23 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import re
import io
import os
import time
import json
import trimesh
import base64
import random
import shutil
import numpy as np
from PIL import Image
from flask import Flask, send_from_directory, make_response, jsonify, request
import DracoPy
from networks.v0.sketch2norm import Sketch2Norm
from networks.v0.sketch2model import Sketch2Model
from networks.v0.sdfrenderer import MyRenderer
from networks.v0.sketch2keypoint import Sketch2Keypoint
s2n = Sketch2Norm()
s2m = Sketch2Model()
s2k = Sketch2Keypoint()
r = MyRenderer(s2m)
def generate_mesh():
root = "sketch_database"
for f in os.listdir(root):
shutil.rmtree("networks/v0/renders")
os.makedirs("networks/v0/renders")
sketch = np.array(Image.open(os.path.join(root, f)).convert('RGB'))
s, n = s2n.predict(sketch)
r.render(s2m, n)
count = 0
while count < 6:
count = 0
for _ in os.listdir("networks/v0/renders"):
count += 1
landmarks = s2k.predict("", "")
obj_path = os.path.join("outs", f.replace(".png", ".obj"))
vertices, faces = s2m.predict_with_template_2(n, obj_path, landmarks)
print(f)
return True
if __name__ == "__main__":
generate_mesh()