Spaces:
Build error
Build error
Comparison of DietNeRF and NeRF
Browse files- app.py +56 -22
- config.json +4 -4
app.py
CHANGED
@@ -21,7 +21,11 @@ def select_model():
|
|
21 |
obj_select = st.selectbox("Select a Scene", ("Mic", "Chair", "Lego", "Ship", "Hotdog"))
|
22 |
DIET_NERF_MODEL_NAME = cfg[obj_select]["DIET_NERF_MODEL_NAME"]
|
23 |
DIET_NERF_FILE_ID = cfg[obj_select]["DIET_NERF_FILE_ID"]
|
24 |
-
|
|
|
|
|
|
|
|
|
25 |
|
26 |
|
27 |
st.title("DietNeRF")
|
@@ -33,29 +37,48 @@ caption = (
|
|
33 |
)
|
34 |
st.markdown(caption)
|
35 |
st.markdown("")
|
36 |
-
DIET_NERF_MODEL_NAME, DIET_NERF_FILE_ID = select_model()
|
37 |
|
38 |
|
39 |
@st.cache(show_spinner=False)
|
40 |
-
def
|
41 |
os.makedirs(MODEL_DIR, exist_ok=True)
|
42 |
-
|
43 |
url = f"https://drive.google.com/uc?id={DIET_NERF_FILE_ID}"
|
44 |
-
gdown.download(url,
|
45 |
-
print(f"Model downloaded from google drive: {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
|
48 |
@st.cache(show_spinner=False, allow_output_mutation=True)
|
49 |
-
def
|
50 |
model, state = load_trained_model(MODEL_DIR, DIET_NERF_MODEL_NAME)
|
51 |
return model, state
|
52 |
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
-
model, state = fetch_model()
|
59 |
pi = math.pi
|
60 |
|
61 |
st.sidebar.markdown(
|
@@ -94,14 +117,25 @@ st.markdown("")
|
|
94 |
|
95 |
with st.spinner("Rendering View..."):
|
96 |
with st.spinner("It may take 2-3 mins. So, why don't you read our report in the meantime"):
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
obj_select = st.selectbox("Select a Scene", ("Mic", "Chair", "Lego", "Ship", "Hotdog"))
|
22 |
DIET_NERF_MODEL_NAME = cfg[obj_select]["DIET_NERF_MODEL_NAME"]
|
23 |
DIET_NERF_FILE_ID = cfg[obj_select]["DIET_NERF_FILE_ID"]
|
24 |
+
|
25 |
+
NERF_MODEL_NAME = cfg[obj_select]["NERF_MODEL_NAME"]
|
26 |
+
NERF_FILE_ID = cfg[obj_select]["NERF_FILE_ID"]
|
27 |
+
|
28 |
+
return DIET_NERF_MODEL_NAME, DIET_NERF_FILE_ID, NERF_MODEL_NAME, NERF_FILE_ID
|
29 |
|
30 |
|
31 |
st.title("DietNeRF")
|
|
|
37 |
)
|
38 |
st.markdown(caption)
|
39 |
st.markdown("")
|
40 |
+
DIET_NERF_MODEL_NAME, DIET_NERF_FILE_ID, NERF_MODEL_NAME, NERF_FILE_ID = select_model()
|
41 |
|
42 |
|
43 |
@st.cache(show_spinner=False)
|
44 |
+
def download_diet_nerf_model():
|
45 |
os.makedirs(MODEL_DIR, exist_ok=True)
|
46 |
+
diet_nerf_model_path = os.path.join(MODEL_DIR, DIET_NERF_MODEL_NAME)
|
47 |
url = f"https://drive.google.com/uc?id={DIET_NERF_FILE_ID}"
|
48 |
+
gdown.download(url, diet_nerf_model_path, quiet=False)
|
49 |
+
print(f"Model downloaded from google drive: {diet_nerf_model_path}")
|
50 |
+
|
51 |
+
|
52 |
+
def download_nerf_model():
|
53 |
+
nerf_model_path = os.path.join(MODEL_DIR, NERF_MODEL_NAME)
|
54 |
+
url = f"https://drive.google.com/uc?id={NERF_FILE_ID}"
|
55 |
+
gdown.download(url, nerf_model_path, quiet=False)
|
56 |
+
print(f"Model downloaded from google drive: {nerf_model_path}")
|
57 |
|
58 |
|
59 |
@st.cache(show_spinner=False, allow_output_mutation=True)
|
60 |
+
def fetch_diet_nerf_model():
|
61 |
model, state = load_trained_model(MODEL_DIR, DIET_NERF_MODEL_NAME)
|
62 |
return model, state
|
63 |
|
64 |
|
65 |
+
@st.cache(show_spinner=False, allow_output_mutation=True)
|
66 |
+
def fetch_nerf_model():
|
67 |
+
model, state = load_trained_model(MODEL_DIR, NERF_MODEL_NAME)
|
68 |
+
return model, state
|
69 |
+
|
70 |
+
|
71 |
+
diet_nerf_model_path = os.path.join(MODEL_DIR, DIET_NERF_MODEL_NAME)
|
72 |
+
if not os.path.isfile(diet_nerf_model_path):
|
73 |
+
download_diet_nerf_model()
|
74 |
+
|
75 |
+
nerf_model_path = os.path.join(MODEL_DIR, NERF_MODEL_NAME)
|
76 |
+
if not os.path.isfile(nerf_model_path):
|
77 |
+
download_nerf_model()
|
78 |
+
|
79 |
+
diet_nerf_model, diet_nerf_state = fetch_diet_nerf_model()
|
80 |
+
nerf_model, nerf_state = fetch_nerf_model()
|
81 |
|
|
|
82 |
pi = math.pi
|
83 |
|
84 |
st.sidebar.markdown(
|
|
|
117 |
|
118 |
with st.spinner("Rendering View..."):
|
119 |
with st.spinner("It may take 2-3 mins. So, why don't you read our report in the meantime"):
|
120 |
+
dn_pred_color, _ = render_predict_from_pose(diet_nerf_state, theta, phi, radius)
|
121 |
+
dn_im = predict_to_image(dn_pred_color)
|
122 |
+
dn_w, _ = dn_im.size
|
123 |
+
dn_new_w = int(2 * dn_w)
|
124 |
+
dn_im = dn_im.resize(size=(dn_new_w, dn_new_w))
|
125 |
+
|
126 |
+
n_pred_color, _ = render_predict_from_pose(nerf_state, theta, phi, radius)
|
127 |
+
n_im = predict_to_image(n_pred_color)
|
128 |
+
n_w, _ = n_im.size
|
129 |
+
n_new_w = int(2 * n_w)
|
130 |
+
n_im = n_im.resize(size=(n_new_w, n_new_w))
|
131 |
+
|
132 |
+
diet_nerf_col, nerf_col = st.beta_columns(1, 1)
|
133 |
+
diet_nerf_col.markdown(
|
134 |
+
"""<h4 style='text-align: center'>DietNerF</h4>""", unsafe_allow_html=True
|
135 |
+
)
|
136 |
+
diet_nerf_col.image(dn_im, use_column_width=True)
|
137 |
+
|
138 |
+
nerf_col.markdown(
|
139 |
+
"""<h4 style='text-align: center'>NerF</h4>""", unsafe_allow_html=True
|
140 |
+
)
|
141 |
+
nerf_col.image(n_im, use_column_width=True)
|
config.json
CHANGED
@@ -7,25 +7,25 @@
|
|
7 |
},
|
8 |
"Lego": {
|
9 |
"DIET_NERF_FILE_ID": "1UaUKgShJTKp5zNQdXvVhkyxgU-2YU3Ay",
|
10 |
-
"NERF_FILE_ID": "
|
11 |
"DIET_NERF_MODEL_NAME": "diet_nerf_lego",
|
12 |
"NERF_MODEL_NAME": "nerf_lego"
|
13 |
},
|
14 |
"Ship": {
|
15 |
"DIET_NERF_FILE_ID": "1Eb4eZ9vn6FcbqLIaBoW-6NlyWr-y0eTW",
|
16 |
-
"NERF_FILE_ID": "
|
17 |
"DIET_NERF_MODEL_NAME": "diet_nerf_ship",
|
18 |
"NERF_MODEL_NAME": "nerf_ship"
|
19 |
},
|
20 |
"Hotdog": {
|
21 |
"DIET_NERF_FILE_ID": "11vNlR4lMvV_AVFgVjZmKMrMWGVG7qhNu",
|
22 |
-
"NERF_FILE_ID": "
|
23 |
"DIET_NERF_MODEL_NAME": "diet_nerf_hotdog",
|
24 |
"NERF_MODEL_NAME": "nerf_hotdog"
|
25 |
},
|
26 |
"Mic": {
|
27 |
"DIET_NERF_FILE_ID": "1vuyCAY8YKLo7OSlTpLJgMem47gJc1W2S",
|
28 |
-
"NERF_FILE_ID": "
|
29 |
"DIET_NERF_MODEL_NAME": "diet_nerf_mic",
|
30 |
"NERF_MODEL_NAME": "nerf_mic"
|
31 |
}
|
|
|
7 |
},
|
8 |
"Lego": {
|
9 |
"DIET_NERF_FILE_ID": "1UaUKgShJTKp5zNQdXvVhkyxgU-2YU3Ay",
|
10 |
+
"NERF_FILE_ID": "16_Mx_p7Sncbb5MoP7JypXAhvmfNfnOwf",
|
11 |
"DIET_NERF_MODEL_NAME": "diet_nerf_lego",
|
12 |
"NERF_MODEL_NAME": "nerf_lego"
|
13 |
},
|
14 |
"Ship": {
|
15 |
"DIET_NERF_FILE_ID": "1Eb4eZ9vn6FcbqLIaBoW-6NlyWr-y0eTW",
|
16 |
+
"NERF_FILE_ID": "1fkChM8-44uSsMcMu6XIFB33nXf58A-Il",
|
17 |
"DIET_NERF_MODEL_NAME": "diet_nerf_ship",
|
18 |
"NERF_MODEL_NAME": "nerf_ship"
|
19 |
},
|
20 |
"Hotdog": {
|
21 |
"DIET_NERF_FILE_ID": "11vNlR4lMvV_AVFgVjZmKMrMWGVG7qhNu",
|
22 |
+
"NERF_FILE_ID": "11vNlR4lMvV_AVFgVjZmKMrMWGVG7qhNu",
|
23 |
"DIET_NERF_MODEL_NAME": "diet_nerf_hotdog",
|
24 |
"NERF_MODEL_NAME": "nerf_hotdog"
|
25 |
},
|
26 |
"Mic": {
|
27 |
"DIET_NERF_FILE_ID": "1vuyCAY8YKLo7OSlTpLJgMem47gJc1W2S",
|
28 |
+
"NERF_FILE_ID": "1JK3vu2F9xnOuhPjYVflMkPp0BcAc4w_9",
|
29 |
"DIET_NERF_MODEL_NAME": "diet_nerf_mic",
|
30 |
"NERF_MODEL_NAME": "nerf_mic"
|
31 |
}
|