Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,8 @@ import streamlit as st
|
|
2 |
import tensorflow as tf
|
3 |
import numpy as np
|
4 |
|
|
|
|
|
5 |
# Setting random seed to obtain reproducible results.
|
6 |
tf.random.set_seed(42)
|
7 |
|
@@ -189,51 +191,6 @@ def render_rgb_depth(model, rays_flat, t_vals, rand=True, train=True):
|
|
189 |
depth_map = tf.reduce_sum(weights * t_vals[:, None, None], axis=-1)
|
190 |
return (rgb, depth_map)
|
191 |
|
192 |
-
def get_translation_t(t):
|
193 |
-
"""Get the translation matrix for movement in t."""
|
194 |
-
matrix = [
|
195 |
-
[1, 0, 0, 0],
|
196 |
-
[0, 1, 0, 0],
|
197 |
-
[0, 0, 1, t],
|
198 |
-
[0, 0, 0, 1],
|
199 |
-
]
|
200 |
-
return tf.convert_to_tensor(matrix, dtype=tf.float32)
|
201 |
-
|
202 |
-
|
203 |
-
def get_rotation_phi(phi):
|
204 |
-
"""Get the rotation matrix for movement in phi."""
|
205 |
-
matrix = [
|
206 |
-
[1, 0, 0, 0],
|
207 |
-
[0, tf.cos(phi), -tf.sin(phi), 0],
|
208 |
-
[0, tf.sin(phi), tf.cos(phi), 0],
|
209 |
-
[0, 0, 0, 1],
|
210 |
-
]
|
211 |
-
return tf.convert_to_tensor(matrix, dtype=tf.float32)
|
212 |
-
|
213 |
-
|
214 |
-
def get_rotation_theta(theta):
|
215 |
-
"""Get the rotation matrix for movement in theta."""
|
216 |
-
matrix = [
|
217 |
-
[tf.cos(theta), 0, -tf.sin(theta), 0],
|
218 |
-
[0, 1, 0, 0],
|
219 |
-
[tf.sin(theta), 0, tf.cos(theta), 0],
|
220 |
-
[0, 0, 0, 1],
|
221 |
-
]
|
222 |
-
return tf.convert_to_tensor(matrix, dtype=tf.float32)
|
223 |
-
|
224 |
-
|
225 |
-
def pose_spherical(theta, phi, t):
|
226 |
-
"""
|
227 |
-
Get the camera to world matrix for the corresponding theta, phi
|
228 |
-
and t.
|
229 |
-
"""
|
230 |
-
c2w = get_translation_t(t)
|
231 |
-
c2w = get_rotation_phi(phi / 180.0 * np.pi) @ c2w
|
232 |
-
c2w = get_rotation_theta(theta / 180.0 * np.pi) @ c2w
|
233 |
-
c2w = np.array([[-1, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) @ c2w
|
234 |
-
return c2w
|
235 |
-
|
236 |
-
|
237 |
def show_rendered_image(r,theta,phi):
|
238 |
# Get the camera to world matrix.
|
239 |
c2w = pose_spherical(theta, phi, r)
|
|
|
2 |
import tensorflow as tf
|
3 |
import numpy as np
|
4 |
|
5 |
+
from transformations import *
|
6 |
+
|
7 |
# Setting random seed to obtain reproducible results.
|
8 |
tf.random.set_seed(42)
|
9 |
|
|
|
191 |
depth_map = tf.reduce_sum(weights * t_vals[:, None, None], axis=-1)
|
192 |
return (rgb, depth_map)
|
193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
def show_rendered_image(r,theta,phi):
|
195 |
# Get the camera to world matrix.
|
196 |
c2w = pose_spherical(theta, phi, r)
|