Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -106,7 +106,7 @@ def build_textured_cube(pil_imgs, face_rotations=None):
|
|
| 106 |
raise ValueError("build_textured_cube attend une liste/tuple de 4 images PIL (front, right, back, left).")
|
| 107 |
|
| 108 |
# defaults rotation & ordre
|
| 109 |
-
default_rots = {"front": 0, "right": 270, "back": 180, "left":
|
| 110 |
# default_rots = {"front": 0, "right": 0, "back": 0, "left": 0, "top": 0, "bottom": 0}
|
| 111 |
if face_rotations is None:
|
| 112 |
face_rotations = default_rots
|
|
@@ -181,7 +181,7 @@ def build_textured_cube(pil_imgs, face_rotations=None):
|
|
| 181 |
except Exception:
|
| 182 |
pass
|
| 183 |
|
| 184 |
-
# ---
|
| 185 |
mtl_path = os.path.join(tmpdir, "parallelep.mtl")
|
| 186 |
with open(mtl_path, "w", encoding="utf-8") as f:
|
| 187 |
f.write("# Material file for parallelepiped\n")
|
|
@@ -198,7 +198,7 @@ def build_textured_cube(pil_imgs, face_rotations=None):
|
|
| 198 |
except Exception:
|
| 199 |
pass
|
| 200 |
|
| 201 |
-
# ---
|
| 202 |
# Convention: +X = right, +Y = front, +Z = up
|
| 203 |
# 8 corners:
|
| 204 |
# (-x,-y,-z), ( x,-y,-z), ( x, y,-z), (-x, y,-z),
|
|
@@ -283,7 +283,7 @@ def build_textured_cube(pil_imgs, face_rotations=None):
|
|
| 283 |
for fname in ["parallelep.obj", "parallelep.mtl"] + list(tex_names.values()):
|
| 284 |
p = os.path.join(tmpdir, fname)
|
| 285 |
if not os.path.exists(p):
|
| 286 |
-
raise FileNotFoundError(f"
|
| 287 |
|
| 288 |
return (os.path.abspath(obj_path), tmpdir)
|
| 289 |
|
|
@@ -296,7 +296,7 @@ def run(fibers: Image.Image, rings: Image.Image, num_steps: int):
|
|
| 296 |
try:
|
| 297 |
outputs = inference(fibers, rings, num_steps)
|
| 298 |
if not (isinstance(outputs, (list, tuple)) and len(outputs) >= 4):
|
| 299 |
-
raise ValueError("user_inference
|
| 300 |
|
| 301 |
pil_imgs = []
|
| 302 |
for im in outputs[:4]:
|
|
|
|
| 106 |
raise ValueError("build_textured_cube attend une liste/tuple de 4 images PIL (front, right, back, left).")
|
| 107 |
|
| 108 |
# defaults rotation & ordre
|
| 109 |
+
default_rots = {"front": 0, "right": 270, "back": 180, "left": 270, "top": 0, "bottom": 0}
|
| 110 |
# default_rots = {"front": 0, "right": 0, "back": 0, "left": 0, "top": 0, "bottom": 0}
|
| 111 |
if face_rotations is None:
|
| 112 |
face_rotations = default_rots
|
|
|
|
| 181 |
except Exception:
|
| 182 |
pass
|
| 183 |
|
| 184 |
+
# --- wri .mtl (références relatives) ---
|
| 185 |
mtl_path = os.path.join(tmpdir, "parallelep.mtl")
|
| 186 |
with open(mtl_path, "w", encoding="utf-8") as f:
|
| 187 |
f.write("# Material file for parallelepiped\n")
|
|
|
|
| 198 |
except Exception:
|
| 199 |
pass
|
| 200 |
|
| 201 |
+
# --- geometry: define quads per face (CCW when looking at the face from the outside)
|
| 202 |
# Convention: +X = right, +Y = front, +Z = up
|
| 203 |
# 8 corners:
|
| 204 |
# (-x,-y,-z), ( x,-y,-z), ( x, y,-z), (-x, y,-z),
|
|
|
|
| 283 |
for fname in ["parallelep.obj", "parallelep.mtl"] + list(tex_names.values()):
|
| 284 |
p = os.path.join(tmpdir, fname)
|
| 285 |
if not os.path.exists(p):
|
| 286 |
+
raise FileNotFoundError(f"Expected file not found : {p}")
|
| 287 |
|
| 288 |
return (os.path.abspath(obj_path), tmpdir)
|
| 289 |
|
|
|
|
| 296 |
try:
|
| 297 |
outputs = inference(fibers, rings, num_steps)
|
| 298 |
if not (isinstance(outputs, (list, tuple)) and len(outputs) >= 4):
|
| 299 |
+
raise ValueError("user_inference must return a list/tuple of 4 images.")
|
| 300 |
|
| 301 |
pil_imgs = []
|
| 302 |
for im in outputs[:4]:
|