Update app.py
Browse files
app.py
CHANGED
@@ -25,7 +25,6 @@ PATH = {
|
|
25 |
|
26 |
prompt_types = ["Point", "Box", "Mask"]
|
27 |
|
28 |
-
@spaces.GPU()
|
29 |
def load_3d_scene(name, sample_idx=-1, type_=None, prompt=None, final=False, new_color=None):
|
30 |
DATASET = name.split('-')[1].replace(" ", "")
|
31 |
path = 'data/' + DATASET + '/' + PATH[DATASET][sample_idx]
|
@@ -198,13 +197,11 @@ def start_segmentation(name=None, sample_idx=None, prompt_type=None, prompt_idx=
|
|
198 |
fig = load_3d_scene(name, sample_idx, TYPE, prompt, final=True, new_color=new_color)
|
199 |
return fig, gr.Textbox(label="Response", value="Segmentation completed successfully!", visible=True)
|
200 |
|
201 |
-
@spaces.GPU()
|
202 |
def update1(datasets):
|
203 |
if 'Objaverse' in datasets:
|
204 |
return gr.Radio(label="Select 3D Object", choices=samples[datasets]), gr.Textbox(label="Response", value="", visible=True)
|
205 |
return gr.Radio(label="Select 3D Scene", choices=samples[datasets]), gr.Textbox(label="Response", value="", visible=True)
|
206 |
|
207 |
-
@spaces.GPU()
|
208 |
def update2(name, sample_idx, prompt_type):
|
209 |
if name == None or sample_idx == None or prompt_type == None:
|
210 |
return gr.Radio(label="Select Prompt Example", choices=[]), gr.Textbox(label="Response", value="", visible=True)
|
@@ -225,7 +222,6 @@ def update2(name, sample_idx, prompt_type):
|
|
225 |
cur = ['Example ' + str(i) for i in range(1, len(info) + 1)]
|
226 |
return gr.Radio(label="Select Prompt Example", choices=cur), gr.Textbox(label="Response", value="", visible=True)
|
227 |
|
228 |
-
@spaces.GPU()
|
229 |
def update3(name, sample_idx, prompt_type, prompt_idx):
|
230 |
if name == None or sample_idx == None or prompt_type == None:
|
231 |
return gr.Textbox(label="Response", value="", visible=True), gr.Slider(minimum=0.01, maximum=0.15, step=0.001, label="Voxel Size", value=0.02)
|
@@ -243,7 +239,6 @@ def update3(name, sample_idx, prompt_type, prompt_idx):
|
|
243 |
|
244 |
return gr.Textbox(label="Response", value="", visible=True), gr.Slider(minimum=0.01, maximum=0.15, step=0.001, label="Voxel Size", value=vx_)
|
245 |
|
246 |
-
@spaces.GPU()
|
247 |
def main():
|
248 |
title = """<h1 style="text-align: center;">
|
249 |
<div style="width: 1.2em; height: 1.2em; display: inline-block;"><img src="https://github.com/ZiyuGuo99/ZiyuGuo99.github.io/blob/main/assets/img/logo.png?raw=true" style='width: 100%; height: 100%; object-fit: contain;' /></div>
|
@@ -302,7 +297,8 @@ def main():
|
|
302 |
start_segment_button.click(start_segmentation, inputs=[sample_dropdown, scene_dropdown, prompt_type_dropdown, prompt_sample_dropdown], outputs=[plot1, response])
|
303 |
|
304 |
#app.queue(status_update_rate="auto")
|
305 |
-
app.
|
|
|
306 |
|
307 |
if __name__ == "__main__":
|
308 |
main()
|
|
|
25 |
|
26 |
prompt_types = ["Point", "Box", "Mask"]
|
27 |
|
|
|
28 |
def load_3d_scene(name, sample_idx=-1, type_=None, prompt=None, final=False, new_color=None):
|
29 |
DATASET = name.split('-')[1].replace(" ", "")
|
30 |
path = 'data/' + DATASET + '/' + PATH[DATASET][sample_idx]
|
|
|
197 |
fig = load_3d_scene(name, sample_idx, TYPE, prompt, final=True, new_color=new_color)
|
198 |
return fig, gr.Textbox(label="Response", value="Segmentation completed successfully!", visible=True)
|
199 |
|
|
|
200 |
def update1(datasets):
|
201 |
if 'Objaverse' in datasets:
|
202 |
return gr.Radio(label="Select 3D Object", choices=samples[datasets]), gr.Textbox(label="Response", value="", visible=True)
|
203 |
return gr.Radio(label="Select 3D Scene", choices=samples[datasets]), gr.Textbox(label="Response", value="", visible=True)
|
204 |
|
|
|
205 |
def update2(name, sample_idx, prompt_type):
|
206 |
if name == None or sample_idx == None or prompt_type == None:
|
207 |
return gr.Radio(label="Select Prompt Example", choices=[]), gr.Textbox(label="Response", value="", visible=True)
|
|
|
222 |
cur = ['Example ' + str(i) for i in range(1, len(info) + 1)]
|
223 |
return gr.Radio(label="Select Prompt Example", choices=cur), gr.Textbox(label="Response", value="", visible=True)
|
224 |
|
|
|
225 |
def update3(name, sample_idx, prompt_type, prompt_idx):
|
226 |
if name == None or sample_idx == None or prompt_type == None:
|
227 |
return gr.Textbox(label="Response", value="", visible=True), gr.Slider(minimum=0.01, maximum=0.15, step=0.001, label="Voxel Size", value=0.02)
|
|
|
239 |
|
240 |
return gr.Textbox(label="Response", value="", visible=True), gr.Slider(minimum=0.01, maximum=0.15, step=0.001, label="Voxel Size", value=vx_)
|
241 |
|
|
|
242 |
def main():
|
243 |
title = """<h1 style="text-align: center;">
|
244 |
<div style="width: 1.2em; height: 1.2em; display: inline-block;"><img src="https://github.com/ZiyuGuo99/ZiyuGuo99.github.io/blob/main/assets/img/logo.png?raw=true" style='width: 100%; height: 100%; object-fit: contain;' /></div>
|
|
|
297 |
start_segment_button.click(start_segmentation, inputs=[sample_dropdown, scene_dropdown, prompt_type_dropdown, prompt_sample_dropdown], outputs=[plot1, response])
|
298 |
|
299 |
#app.queue(status_update_rate="auto")
|
300 |
+
app.queue(max_size=20, api_open=False)
|
301 |
+
app.launch(max_threads=400)
|
302 |
|
303 |
if __name__ == "__main__":
|
304 |
main()
|