Spaces:
Sleeping
Sleeping
Vincent-Tann
commited on
Commit
•
a780b40
1
Parent(s):
f27a827
Add 5 types of scene. Use [git lfs] to track glb and ply.
Browse files- .gitattributes +2 -0
- 2glb.py +7 -0
- appyibu.py → _appyibu.py +0 -0
- app.py +61 -21
- objects_info/objects_info_scene0014_00.npy +3 -0
- objects_info/objects_info_scene0024_00.npy +3 -0
- objects_info/objects_info_scene0051_00.npy +3 -0
- objects_info/objects_info_scene0114_00.npy +3 -0
- objects_info/objects_info_scene0335_01.npy +3 -0
- scenes/scene0014_00_vh_clean_2_aligned.glb +3 -0
- scenes/scene0014_00_vh_clean_2_aligned.ply +3 -0
- scenes/scene0024_00_vh_clean_2_aligned.glb +3 -0
- scenes/scene0024_00_vh_clean_2_aligned.ply +3 -0
- scenes/scene0051_00_vh_clean_2_aligned.glb +3 -0
- scenes/scene0051_00_vh_clean_2_aligned.ply +3 -0
- scenes/scene0114_00_vh_clean_2_aligned.glb +3 -0
- scenes/scene0114_00_vh_clean_2_aligned.ply +3 -0
- scenes/scene0335_01_vh_clean_2_aligned.glb +3 -0
- scenes/scene0335_01_vh_clean_2_aligned.ply +3 -0
.gitattributes
CHANGED
@@ -35,3 +35,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
scenes/scene0132_00_vh_clean_2_aligned.glb filter=lfs diff=lfs merge=lfs -text
|
37 |
scenes/scene0132_00_vh_clean_2_aligned.ply filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
scenes/scene0132_00_vh_clean_2_aligned.glb filter=lfs diff=lfs merge=lfs -text
|
37 |
scenes/scene0132_00_vh_clean_2_aligned.ply filter=lfs diff=lfs merge=lfs -text
|
38 |
+
*.ply filter=lfs diff=lfs merge=lfs -text
|
39 |
+
*.glb filter=lfs diff=lfs merge=lfs -text
|
2glb.py
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from display_model import ply_to_glb
|
2 |
+
|
3 |
+
|
4 |
+
if __name__ == '__main__':
|
5 |
+
for name in ['scene0014_00', 'scene0024_00', 'scene0051_00', 'scene0114_00','scene0335_01']:
|
6 |
+
ply_to_glb(ply_file=f"scenes/{name}_vh_clean_2_aligned.ply", glb_file=f"scenes/{name}_vh_clean_2_aligned.glb")
|
7 |
+
print(f"{name} finish")
|
appyibu.py → _appyibu.py
RENAMED
File without changes
|
app.py
CHANGED
@@ -3,12 +3,26 @@ import gradio as gr
|
|
3 |
|
4 |
from display_model import *
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
def insert_user_none_between_assistant(messages):
|
14 |
# 初始化结果列表
|
@@ -89,9 +103,10 @@ def process_instruction_callback(inp_api_key, instruction, llm_name):
|
|
89 |
gradio_messages.append(gradio_message)
|
90 |
|
91 |
# return gradio_messages
|
92 |
-
return new_glb_file, gradio_messages
|
93 |
|
94 |
def generate_answer_glb(answer_content):
|
|
|
95 |
from transcrib3d_main import extract_answer_id_from_last_line
|
96 |
last_line = answer_content.splitlines()[-1] if len(answer_content) > 0 else ''
|
97 |
answer_id, _ = extract_answer_id_from_last_line(last_line)
|
@@ -112,53 +127,75 @@ def llm_dropdown_callback(llm_name):
|
|
112 |
print("llm_name in callback:",llm_name)
|
113 |
return llm_name
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
with gr.Blocks() as demo:
|
116 |
gr.Markdown("## Transcrib3D-Demo")
|
117 |
with gr.Row():
|
118 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
model3d = gr.Model3D(
|
120 |
-
value="scenes/
|
121 |
-
label="ScanNet
|
|
|
122 |
camera_position=(90,120,8),
|
123 |
zoom_speed=0.25,
|
124 |
# height=635,
|
125 |
height=725
|
126 |
)
|
127 |
-
#
|
128 |
-
|
129 |
# gr.Markdown("🖱️:arrow_up::arrow_down:: SCROLL to zoom in/out.\t🖱️🔁 DRAG to rotate.\tCTRL+🖱️🔁 Press CTRL and DRAG to pan.")
|
130 |
html_content = """
|
131 |
<div style='text-align: center;'>
|
132 |
🖱️🔼🔽: SCROLL to zoom in/out. 🖱️🔁: DRAG to rotate. [CTRL]+🖱️🔁: Press CTRL and DRAG to pan.
|
|
|
133 |
</div>
|
134 |
"""
|
135 |
gr.HTML(value=html_content)
|
136 |
|
137 |
with gr.Column():
|
138 |
-
|
139 |
-
inp_api_key = gr.Textbox(
|
140 |
-
|
|
|
|
|
|
|
141 |
llm_dropdown = gr.Dropdown(
|
142 |
# choices=['gpt-4-turbo','gpt-4','gpt-3.5-turbo'],
|
143 |
-
choices=['gpt-4-0125-preview', 'gpt-4-1106-preview', 'gpt-3.5-turbo-0125'],
|
144 |
label="LLM Selection",
|
145 |
-
type='value'
|
|
|
146 |
)
|
147 |
-
|
148 |
-
|
149 |
-
llm_dropdown.select(fn=llm_dropdown_callback, inputs=llm_dropdown, outputs=llm_name_text)
|
150 |
-
|
151 |
|
|
|
152 |
user_instruction_textbox = gr.Textbox(
|
153 |
label="Instruction",
|
154 |
placeholder="Describe an object in the scene with its attributes and its relation with other objects, e.g. 'The largest table in the scene.",
|
155 |
# scale=4
|
156 |
)
|
|
|
157 |
bt = gr.Button(
|
158 |
value="Submit",
|
159 |
# scale=1
|
160 |
)
|
161 |
-
|
162 |
dialogue = gr.Chatbot(
|
163 |
height=470
|
164 |
# value = [["1","2"], [None, '3']]
|
@@ -171,6 +208,9 @@ with gr.Blocks() as demo:
|
|
171 |
bt.click(fn=process_instruction_callback, inputs=[inp_api_key, user_instruction_textbox,llm_name_text], outputs=[model3d,dialogue])
|
172 |
user_instruction_textbox.submit(fn=process_instruction_callback, inputs=[inp_api_key, user_instruction_textbox, llm_name_text], outputs=[model3d,dialogue])
|
173 |
|
|
|
|
|
|
|
174 |
# 直接用lambda函数定义一个映射
|
175 |
# type(user_instruction_textbox.value)
|
176 |
# user_instruction_textbox.
|
|
|
3 |
|
4 |
from display_model import *
|
5 |
|
6 |
+
default_llm = 'gpt-3.5-turbo-0125'
|
7 |
+
# scan_id = "scene0132_00"
|
8 |
+
scan_id_mapper={
|
9 |
+
'Living Room':'scene0024_00',
|
10 |
+
'Bedroom':'scene0051_00', #144
|
11 |
+
'Kitchen':'scene0335_01', #164 197
|
12 |
+
'Bathroom':'scene0014_00', #14 26
|
13 |
+
'Office':'scene0114_00'
|
14 |
+
# gym 428
|
15 |
+
}
|
16 |
+
defualt_scene_type = 'Living Room'
|
17 |
+
scan_id = scan_id_mapper[defualt_scene_type]
|
18 |
+
|
19 |
+
def get_path(scan_id):
|
20 |
+
ply_file = os.path.join("scenes", f"{scan_id}_vh_clean_2_aligned.ply")
|
21 |
+
glb_file = os.path.join("scenes", f"{scan_id}_vh_clean_2_aligned.glb")
|
22 |
+
new_ply_file = os.path.join("scenes", f"{scan_id}_vh_clean_2_aligned_AddBox.ply")
|
23 |
+
new_glb_file = os.path.join("scenes", f"{scan_id}_vh_clean_2_aligned_AddBox.glb")
|
24 |
+
objects_info_file = os.path.join("objects_info", f"objects_info_{scan_id}.npy")
|
25 |
+
return {"ply_file":ply_file, "glb_file":glb_file, "new_ply_file":new_ply_file, "new_glb_file":new_glb_file, "objects_info_file":objects_info_file}
|
26 |
|
27 |
def insert_user_none_between_assistant(messages):
|
28 |
# 初始化结果列表
|
|
|
103 |
gradio_messages.append(gradio_message)
|
104 |
|
105 |
# return gradio_messages
|
106 |
+
return get_path(scan_id)['new_glb_file'], gradio_messages
|
107 |
|
108 |
def generate_answer_glb(answer_content):
|
109 |
+
ply_file, glb_file, new_ply_file, new_glb_file, objects_info_file = get_path(scan_id).values()
|
110 |
from transcrib3d_main import extract_answer_id_from_last_line
|
111 |
last_line = answer_content.splitlines()[-1] if len(answer_content) > 0 else ''
|
112 |
answer_id, _ = extract_answer_id_from_last_line(last_line)
|
|
|
127 |
print("llm_name in callback:",llm_name)
|
128 |
return llm_name
|
129 |
|
130 |
+
def scene_type_dropdown_callback(scene_type):
|
131 |
+
# update scan_id as a global vairable
|
132 |
+
global scan_id
|
133 |
+
scan_id = scan_id_mapper[scene_type]
|
134 |
+
print("scan_id inside scene_type_dropdown_callback:",scan_id)
|
135 |
+
return get_path(scan_id)['glb_file']
|
136 |
+
|
137 |
with gr.Blocks() as demo:
|
138 |
gr.Markdown("## Transcrib3D-Demo")
|
139 |
with gr.Row():
|
140 |
with gr.Column():
|
141 |
+
# Left-1: Scene Type Selection
|
142 |
+
scene_type_dropdown = gr.Dropdown(
|
143 |
+
choices=['Living Room', 'Bedroom', 'Kitchen', 'Bathroom', 'Office'],
|
144 |
+
label='Scene Type',
|
145 |
+
type='value',
|
146 |
+
value=defualt_scene_type
|
147 |
+
)
|
148 |
+
scan_id_text = gr.Text(visible=False)
|
149 |
+
|
150 |
+
# Left-2: 3D Scene
|
151 |
model3d = gr.Model3D(
|
152 |
+
value=f"scenes/{scan_id}_vh_clean_2_aligned.glb",
|
153 |
+
# label=f"ScanNet {scan_id}", #how to update this label????
|
154 |
+
label="3D Scene from ScanNet Dataset",
|
155 |
camera_position=(90,120,8),
|
156 |
zoom_speed=0.25,
|
157 |
# height=635,
|
158 |
height=725
|
159 |
)
|
160 |
+
# Left-3: Tips
|
|
|
161 |
# gr.Markdown("🖱️:arrow_up::arrow_down:: SCROLL to zoom in/out.\t🖱️🔁 DRAG to rotate.\tCTRL+🖱️🔁 Press CTRL and DRAG to pan.")
|
162 |
html_content = """
|
163 |
<div style='text-align: center;'>
|
164 |
🖱️🔼🔽: SCROLL to zoom in/out. 🖱️🔁: DRAG to rotate. [CTRL]+🖱️🔁: Press CTRL and DRAG to pan.
|
165 |
+
<br>It may takes ~10 seconds to load the 3D scene.
|
166 |
</div>
|
167 |
"""
|
168 |
gr.HTML(value=html_content)
|
169 |
|
170 |
with gr.Column():
|
171 |
+
# Right-1: Openai Api Key Input
|
172 |
+
inp_api_key = gr.Textbox(
|
173 |
+
label='OpenAI API Key (this is not stored anywhere)',
|
174 |
+
placeholder='You can generate key at https://platform.openai.com/api-keys',
|
175 |
+
lines=1)
|
176 |
+
# Right-2: LLM Selection
|
177 |
llm_dropdown = gr.Dropdown(
|
178 |
# choices=['gpt-4-turbo','gpt-4','gpt-3.5-turbo'],
|
179 |
+
choices=['gpt-4', 'gpt-4-0125-preview', 'gpt-4-1106-preview', 'gpt-3.5-turbo-0125'],
|
180 |
label="LLM Selection",
|
181 |
+
type='value',
|
182 |
+
value=default_llm
|
183 |
)
|
184 |
+
llm_name_text = gr.Text(value=default_llm, visible=False)
|
185 |
+
|
|
|
|
|
186 |
|
187 |
+
# Right-3: User Instruction Input
|
188 |
user_instruction_textbox = gr.Textbox(
|
189 |
label="Instruction",
|
190 |
placeholder="Describe an object in the scene with its attributes and its relation with other objects, e.g. 'The largest table in the scene.",
|
191 |
# scale=4
|
192 |
)
|
193 |
+
# Right-4: Submit Button
|
194 |
bt = gr.Button(
|
195 |
value="Submit",
|
196 |
# scale=1
|
197 |
)
|
198 |
+
# Right-5: Dialogue
|
199 |
dialogue = gr.Chatbot(
|
200 |
height=470
|
201 |
# value = [["1","2"], [None, '3']]
|
|
|
208 |
bt.click(fn=process_instruction_callback, inputs=[inp_api_key, user_instruction_textbox,llm_name_text], outputs=[model3d,dialogue])
|
209 |
user_instruction_textbox.submit(fn=process_instruction_callback, inputs=[inp_api_key, user_instruction_textbox, llm_name_text], outputs=[model3d,dialogue])
|
210 |
|
211 |
+
scene_type_dropdown.select(fn=scene_type_dropdown_callback, inputs=scene_type_dropdown, outputs=model3d)
|
212 |
+
llm_dropdown.select(fn=llm_dropdown_callback, inputs=llm_dropdown, outputs=llm_name_text)
|
213 |
+
|
214 |
# 直接用lambda函数定义一个映射
|
215 |
# type(user_instruction_textbox.value)
|
216 |
# user_instruction_textbox.
|
objects_info/objects_info_scene0014_00.npy
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:98e3a5c5e11ecaa11c3569b2c9c051bca997b0089d523fecbb9ee038a602176c
|
3 |
+
size 19477
|
objects_info/objects_info_scene0024_00.npy
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eac6b438ffa9c8b88a741410507563ccf0d6ac94650b66924ee649315b84628a
|
3 |
+
size 38887
|
objects_info/objects_info_scene0051_00.npy
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bf6a9fa7b7ed75d0eb1189a88c742813c56ff1968097cbb656790704e3ef4988
|
3 |
+
size 30011
|
objects_info/objects_info_scene0114_00.npy
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2e8b329206fa085dbdf66948dab3193196424cd53413ff719cd9771f767c6db6
|
3 |
+
size 17584
|
objects_info/objects_info_scene0335_01.npy
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c4ed178d800636f943c9660e9bd1c14dd0cd58c9e750867886459a342ff05a0c
|
3 |
+
size 36433
|
scenes/scene0014_00_vh_clean_2_aligned.glb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:05e13ed5485a96bf0460dce00407c754a3b4c69d586e303261f6daa058438e56
|
3 |
+
size 3779956
|
scenes/scene0014_00_vh_clean_2_aligned.ply
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:56164fd1202ea66a3675d934e3ec6218fc7bc255a3659d822f6427315cd250d0
|
3 |
+
size 3964386
|
scenes/scene0024_00_vh_clean_2_aligned.glb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e0f3b3ea5ef0a4cc517d5d542b85700a66c73827cda7280d1f68db65a822ae6c
|
3 |
+
size 10566164
|
scenes/scene0024_00_vh_clean_2_aligned.ply
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1b062560cc2e4758115437f546bf4b240dcdd5526ea3cfd40ab8e84c85ee74b5
|
3 |
+
size 11080892
|
scenes/scene0051_00_vh_clean_2_aligned.glb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:deb4e2ba8e2341361dbfe8374a09f60aa54505b76b91b88d2b32d6e09424df53
|
3 |
+
size 8726472
|
scenes/scene0051_00_vh_clean_2_aligned.ply
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:edf032cc01a92402c7709f254ab79b6b510adf1a659d9894bb06ecc167e2d4db
|
3 |
+
size 9152338
|
scenes/scene0114_00_vh_clean_2_aligned.glb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dc2edd57267729ce1fda22e7e9e26080c17629d5e7f9a51798d1fe1f6efaa634
|
3 |
+
size 6832076
|
scenes/scene0114_00_vh_clean_2_aligned.ply
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9de606b26a5873e819f5f97685a3cc038ca55852c2f12226a9f537a49ef636c4
|
3 |
+
size 7164602
|
scenes/scene0335_01_vh_clean_2_aligned.glb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:edb7fce2b83a44eaa11edc311faa46131ef863561998c063207647d46a34fdaf
|
3 |
+
size 7261404
|
scenes/scene0335_01_vh_clean_2_aligned.ply
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dfe80b74708cbacfd499d282edc549ef6276192fc38e80469346c110f755dc7b
|
3 |
+
size 7614742
|