hassiahk commited on
Commit
8817db0
β€’
1 Parent(s): d64409f

Remove NeRF models

Browse files
Files changed (1) hide show
  1. app.py +57 -59
app.py CHANGED
@@ -28,8 +28,40 @@ def select_model(obj_select):
28
 
29
  return DIET_NERF_MODEL_NAME, DIET_NERF_FILE_ID, NERF_MODEL_NAME, NERF_FILE_ID
30
 
 
31
 
32
  st.title("DietNeRF")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  caption = (
34
  "`DietNeRF` achieves state-of-the-art few-shot learning capacity in 3D model reconstruction. "
35
  "Thanks to the 2D supervision by `CLIP (aka. Semantic Consisteny Loss)`, "
@@ -51,11 +83,11 @@ def download_diet_nerf_model():
51
  print(f"Model downloaded from google drive: {diet_nerf_model_path}")
52
 
53
 
54
- def download_nerf_model():
55
- nerf_model_path = os.path.join(MODEL_DIR, NERF_MODEL_NAME)
56
- url = f"https://drive.google.com/uc?id={NERF_FILE_ID}"
57
- gdown.download(url, nerf_model_path, quiet=False)
58
- print(f"Model downloaded from google drive: {nerf_model_path}")
59
 
60
 
61
  @st.cache(show_spinner=False, allow_output_mutation=True)
@@ -64,56 +96,22 @@ def fetch_diet_nerf_model():
64
  return model, state
65
 
66
 
67
- @st.cache(show_spinner=False, allow_output_mutation=True)
68
- def fetch_nerf_model():
69
- model, state = load_trained_model(MODEL_DIR, NERF_MODEL_NAME)
70
- return model, state
71
 
72
 
73
  diet_nerf_model_path = os.path.join(MODEL_DIR, DIET_NERF_MODEL_NAME)
74
  if not os.path.isfile(diet_nerf_model_path):
75
  download_diet_nerf_model()
76
 
77
- nerf_model_path = os.path.join(MODEL_DIR, NERF_MODEL_NAME)
78
- if not os.path.isfile(nerf_model_path):
79
- download_nerf_model()
80
 
81
  diet_nerf_model, diet_nerf_state = fetch_diet_nerf_model()
82
- nerf_model, nerf_state = fetch_nerf_model()
83
-
84
- pi = math.pi
85
-
86
- st.sidebar.markdown(
87
- """
88
- <style>
89
- .aligncenter {
90
- text-align: center;
91
- }
92
- </style>
93
- <p class="aligncenter">
94
- <img src="https://user-images.githubusercontent.com/77657524/126361638-4aad58e8-4efb-4fc5-bf78-f53d03799e1e.png" width="420" height="400"/>
95
- </p>
96
- """,
97
- unsafe_allow_html=True,
98
- )
99
- st.sidebar.markdown(
100
- """
101
- <p style='text-align: center'>
102
- <a href="https://github.com/codestella/putting-nerf-on-a-diet" target="_blank">GitHub</a> | <a href="https://www.notion.so/DietNeRF-Putting-NeRF-on-a-Diet-4aeddae95d054f1d91686f02bdb74745" target="_blank">Project Report</a>
103
- </p>
104
- """,
105
- unsafe_allow_html=True,
106
- )
107
- st.sidebar.header("SELECT YOUR VIEW DIRECTION")
108
- theta = st.sidebar.slider(
109
- "Theta", min_value=-pi, max_value=pi, step=0.5, value=0.0, help="Rotational angle in Horizontal direction"
110
- )
111
- phi = st.sidebar.slider(
112
- "Phi", min_value=0.0, max_value=0.5 * pi, step=0.1, value=1.0, help="Rotational angle in Vertical direction"
113
- )
114
- radius = st.sidebar.slider(
115
- "Radius", min_value=2.0, max_value=6.0, step=1.0, value=3.0, help="Distance between object and the viewer"
116
- )
117
 
118
  st.markdown("")
119
 
@@ -127,21 +125,21 @@ with st.spinner("Rendering View..."):
127
  dn_new_w = int(2 * dn_w)
128
  dn_im = dn_im.resize(size=(dn_new_w, dn_new_w))
129
 
130
- n_pred_color, _ = render_predict_from_pose(nerf_state, theta, phi, radius)
131
- n_im = predict_to_image(n_pred_color)
132
- n_w, _ = n_im.size
133
- n_new_w = int(2 * n_w)
134
- n_im = n_im.resize(size=(n_new_w, n_new_w))
135
 
136
  diet_nerf_col, nerf_col = st.beta_columns([1, 1])
137
  diet_nerf_col.markdown("""<h4 style='text-align: center'>DietNeRF</h4>""", unsafe_allow_html=True)
138
  diet_nerf_col.image(dn_im, use_column_width=True)
139
 
140
- nerf_col.markdown("""<h4 style='text-align: center'>NeRF</h4>""", unsafe_allow_html=True)
141
- nerf_col.image(n_im, use_column_width=True)
142
 
143
- st.markdown(
144
- "> πŸ“’ NOTE: The views may look similar to you but see the "
145
- "[Experimental Results](https://www.notion.so/DietNeRF-Putting-NeRF-on-a-Diet-4aeddae95d054f1d91686f02bdb74745#0f6bc8f1008d4765b9b4635999626d4b) "
146
- "section in our report to get a detailed comparison of differences between `DietNeRF` and `NeRF`."
147
- )
 
28
 
29
  return DIET_NERF_MODEL_NAME, DIET_NERF_FILE_ID, NERF_MODEL_NAME, NERF_FILE_ID
30
 
31
+ pi = math.pi
32
 
33
  st.title("DietNeRF")
34
+ st.sidebar.markdown(
35
+ """
36
+ <style>
37
+ .aligncenter {
38
+ text-align: center;
39
+ }
40
+ </style>
41
+ <p class="aligncenter">
42
+ <img src="https://user-images.githubusercontent.com/77657524/126361638-4aad58e8-4efb-4fc5-bf78-f53d03799e1e.png" width="420" height="400"/>
43
+ </p>
44
+ """,
45
+ unsafe_allow_html=True,
46
+ )
47
+ st.sidebar.markdown(
48
+ """
49
+ <p style='text-align: center'>
50
+ <a href="https://github.com/codestella/putting-nerf-on-a-diet" target="_blank">GitHub</a> | <a href="https://www.notion.so/DietNeRF-Putting-NeRF-on-a-Diet-4aeddae95d054f1d91686f02bdb74745" target="_blank">Project Report</a>
51
+ </p>
52
+ """,
53
+ unsafe_allow_html=True,
54
+ )
55
+ st.sidebar.header("SELECT YOUR VIEW DIRECTION")
56
+ theta = st.sidebar.slider(
57
+ "Theta", min_value=-pi, max_value=pi, step=0.5, value=0.0, help="Rotational angle in Horizontal direction"
58
+ )
59
+ phi = st.sidebar.slider(
60
+ "Phi", min_value=0.0, max_value=0.5 * pi, step=0.1, value=1.0, help="Rotational angle in Vertical direction"
61
+ )
62
+ radius = st.sidebar.slider(
63
+ "Radius", min_value=2.0, max_value=6.0, step=1.0, value=3.0, help="Distance between object and the viewer"
64
+ )
65
  caption = (
66
  "`DietNeRF` achieves state-of-the-art few-shot learning capacity in 3D model reconstruction. "
67
  "Thanks to the 2D supervision by `CLIP (aka. Semantic Consisteny Loss)`, "
 
83
  print(f"Model downloaded from google drive: {diet_nerf_model_path}")
84
 
85
 
86
+ # def download_nerf_model():
87
+ # nerf_model_path = os.path.join(MODEL_DIR, NERF_MODEL_NAME)
88
+ # url = f"https://drive.google.com/uc?id={NERF_FILE_ID}"
89
+ # gdown.download(url, nerf_model_path, quiet=False)
90
+ # print(f"Model downloaded from google drive: {nerf_model_path}")
91
 
92
 
93
  @st.cache(show_spinner=False, allow_output_mutation=True)
 
96
  return model, state
97
 
98
 
99
+ # @st.cache(show_spinner=False, allow_output_mutation=True)
100
+ # def fetch_nerf_model():
101
+ # model, state = load_trained_model(MODEL_DIR, NERF_MODEL_NAME)
102
+ # return model, state
103
 
104
 
105
  diet_nerf_model_path = os.path.join(MODEL_DIR, DIET_NERF_MODEL_NAME)
106
  if not os.path.isfile(diet_nerf_model_path):
107
  download_diet_nerf_model()
108
 
109
+ # nerf_model_path = os.path.join(MODEL_DIR, NERF_MODEL_NAME)
110
+ # if not os.path.isfile(nerf_model_path):
111
+ # download_nerf_model()
112
 
113
  diet_nerf_model, diet_nerf_state = fetch_diet_nerf_model()
114
+ # nerf_model, nerf_state = fetch_nerf_model()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
 
116
  st.markdown("")
117
 
 
125
  dn_new_w = int(2 * dn_w)
126
  dn_im = dn_im.resize(size=(dn_new_w, dn_new_w))
127
 
128
+ # n_pred_color, _ = render_predict_from_pose(nerf_state, theta, phi, radius)
129
+ # n_im = predict_to_image(n_pred_color)
130
+ # n_w, _ = n_im.size
131
+ # n_new_w = int(2 * n_w)
132
+ # n_im = n_im.resize(size=(n_new_w, n_new_w))
133
 
134
  diet_nerf_col, nerf_col = st.beta_columns([1, 1])
135
  diet_nerf_col.markdown("""<h4 style='text-align: center'>DietNeRF</h4>""", unsafe_allow_html=True)
136
  diet_nerf_col.image(dn_im, use_column_width=True)
137
 
138
+ # nerf_col.markdown("""<h4 style='text-align: center'>NeRF</h4>""", unsafe_allow_html=True)
139
+ # nerf_col.image(n_im, use_column_width=True)
140
 
141
+ # st.markdown(
142
+ # "> πŸ“’ NOTE: The views may look similar to you but see the "
143
+ # "[Experimental Results](https://www.notion.so/DietNeRF-Putting-NeRF-on-a-Diet-4aeddae95d054f1d91686f02bdb74745#0f6bc8f1008d4765b9b4635999626d4b) "
144
+ # "section in our report to get a detailed comparison of differences between `DietNeRF` and `NeRF`."
145
+ # )