Spaces:
Runtime error
Runtime error
jackyliang42
commited on
Commit
·
5f6073b
1
Parent(s):
117bf34
input validation
Browse files
app.py
CHANGED
@@ -69,6 +69,12 @@ class DemoRunner:
|
|
69 |
return lmp_tabletop_ui
|
70 |
|
71 |
def setup(self, api_key, model_name, n_blocks, n_bowls):
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
openai.api_key = api_key
|
73 |
self._model_name = model_name
|
74 |
|
@@ -87,16 +93,15 @@ class DemoRunner:
|
|
87 |
|
88 |
def run(self, instruction):
|
89 |
if self._env is None:
|
90 |
-
return 'Please run setup first'
|
91 |
|
92 |
self._env.cache_video = []
|
93 |
self._md_logger.clear()
|
94 |
|
95 |
try:
|
96 |
self._lmp_tabletop_ui(instruction, f'objects = {self._env.object_list}')
|
97 |
-
run_info = self._md_logger.get_log()
|
98 |
except Exception as e:
|
99 |
-
|
100 |
|
101 |
video_file_name = None
|
102 |
if self._env.cache_video:
|
@@ -104,7 +109,7 @@ class DemoRunner:
|
|
104 |
video_file_name = NamedTemporaryFile(suffix='.mp4').name
|
105 |
rendered_clip.write_videofile(video_file_name, fps=25)
|
106 |
|
107 |
-
return
|
108 |
|
109 |
|
110 |
if __name__ == '__main__':
|
@@ -129,7 +134,7 @@ if __name__ == '__main__':
|
|
129 |
inp_n_bowls = gr.Slider(label='Number of Bowls', minimum=0, maximum=4, value=3, step=1)
|
130 |
|
131 |
btn_setup = gr.Button("Setup/Reset Env")
|
132 |
-
info_setup = gr.Markdown(label='Setup Info'
|
133 |
with gr.Column():
|
134 |
img_setup = gr.Image(label='Current Simulation')
|
135 |
|
|
|
69 |
return lmp_tabletop_ui
|
70 |
|
71 |
def setup(self, api_key, model_name, n_blocks, n_bowls):
|
72 |
+
if not api_key:
|
73 |
+
return 'Please enter your OpenAI API key!', None
|
74 |
+
|
75 |
+
if n_blocks + n_bowls == 0:
|
76 |
+
return 'Please select at least one object!', None
|
77 |
+
|
78 |
openai.api_key = api_key
|
79 |
self._model_name = model_name
|
80 |
|
|
|
93 |
|
94 |
def run(self, instruction):
|
95 |
if self._env is None:
|
96 |
+
return 'Please run setup first!', None, None
|
97 |
|
98 |
self._env.cache_video = []
|
99 |
self._md_logger.clear()
|
100 |
|
101 |
try:
|
102 |
self._lmp_tabletop_ui(instruction, f'objects = {self._env.object_list}')
|
|
|
103 |
except Exception as e:
|
104 |
+
return str(e), None, None
|
105 |
|
106 |
video_file_name = None
|
107 |
if self._env.cache_video:
|
|
|
109 |
video_file_name = NamedTemporaryFile(suffix='.mp4').name
|
110 |
rendered_clip.write_videofile(video_file_name, fps=25)
|
111 |
|
112 |
+
return self._md_logger.get_log(), self._env.get_camera_image(), video_file_name
|
113 |
|
114 |
|
115 |
if __name__ == '__main__':
|
|
|
134 |
inp_n_bowls = gr.Slider(label='Number of Bowls', minimum=0, maximum=4, value=3, step=1)
|
135 |
|
136 |
btn_setup = gr.Button("Setup/Reset Env")
|
137 |
+
info_setup = gr.Markdown(label='Setup Info')
|
138 |
with gr.Column():
|
139 |
img_setup = gr.Image(label='Current Simulation')
|
140 |
|