Spaces:
Runtime error
Runtime error
Commit
·
a5a934b
1
Parent(s):
4def7cc
Update utils/conversion.py
Browse files- utils/conversion.py +3 -3
utils/conversion.py
CHANGED
|
@@ -203,19 +203,19 @@ def uv2pixel(uv, w=1024, h=512, axis=None, need_round=True):
|
|
| 203 |
elif axis == 0:
|
| 204 |
pu = uv * w - 0.5
|
| 205 |
if need_round:
|
| 206 |
-
pu = pu.round().astype(np.
|
| 207 |
return pu
|
| 208 |
elif axis == 1:
|
| 209 |
pv = uv * h - 0.5
|
| 210 |
if need_round:
|
| 211 |
-
pv = pv.round().astype(np.
|
| 212 |
return pv
|
| 213 |
else:
|
| 214 |
assert False, "axis error"
|
| 215 |
|
| 216 |
lst = [pu, pv]
|
| 217 |
if need_round:
|
| 218 |
-
pixel = np.concatenate(lst, axis=-1).round().astype(np.
|
| 219 |
dim=-1).round().int()
|
| 220 |
else:
|
| 221 |
pixel = np.concatenate(lst, axis=-1) if isinstance(uv, np.ndarray) else torch.cat(lst, dim=-1)
|
|
|
|
| 203 |
elif axis == 0:
|
| 204 |
pu = uv * w - 0.5
|
| 205 |
if need_round:
|
| 206 |
+
pu = pu.round().astype(np.int32) if isinstance(uv, np.ndarray) else pu.round().int()
|
| 207 |
return pu
|
| 208 |
elif axis == 1:
|
| 209 |
pv = uv * h - 0.5
|
| 210 |
if need_round:
|
| 211 |
+
pv = pv.round().astype(np.int32) if isinstance(uv, np.ndarray) else pv.round().int()
|
| 212 |
return pv
|
| 213 |
else:
|
| 214 |
assert False, "axis error"
|
| 215 |
|
| 216 |
lst = [pu, pv]
|
| 217 |
if need_round:
|
| 218 |
+
pixel = np.concatenate(lst, axis=-1).round().astype(np.int32) if isinstance(uv, np.ndarray) else torch.cat(lst,
|
| 219 |
dim=-1).round().int()
|
| 220 |
else:
|
| 221 |
pixel = np.concatenate(lst, axis=-1) if isinstance(uv, np.ndarray) else torch.cat(lst, dim=-1)
|