gensim2 commited on
Commit
5d8f3c8
·
1 Parent(s): de34129

update gradio

Browse files
app.py CHANGED
@@ -33,15 +33,16 @@ class DemoRunner:
33
  hydra.initialize(version_base="1.2", config_path='cliport/cfg')
34
  self._cfg = hydra.compose(config_name="data")
35
 
36
- def setup(self, api_key):
37
  cfg = self._cfg
 
38
  openai.api_key = api_key
39
  cfg['model_output_dir'] = 'temp'
40
  cfg['prompt_folder'] = 'bottomup_task_generation_prompt'
41
  set_gpt_model(cfg['gpt_model'])
42
- cfg['load_memory'] = True
43
  cfg['use_template'] = True
44
- cfg['task_description_candidate_num'] = 10
45
  cfg['record']['save_video'] = True
46
 
47
  print("cfg = ", cfg)
@@ -54,8 +55,9 @@ class DemoRunner:
54
 
55
  return info
56
 
57
- def setup_top_down(self, api_key, target_task_name):
58
  cfg = self._cfg
 
59
  openai.api_key = api_key
60
  cfg['model_output_dir'] = 'temp'
61
  cfg['prompt_folder'] = 'topdown_task_generation_prompt'
@@ -105,19 +107,21 @@ class DemoRunner:
105
  print("run example cost = ", t2 - t1, " s")
106
 
107
 
108
- def setup(api_key, option_choice, target_task_name):
109
  print(option_choice)
110
  if not api_key:
111
  return 'Please enter your OpenAI API key!', None
112
 
 
 
113
  if option_choice is None:
114
  return 'Please choose the mode!', None
115
  demo_runner = DemoRunner()
116
 
117
  if option_choice == 'top-down':
118
- info = demo_runner.setup_top_down(api_key, target_task_name) + option_choice
119
  elif option_choice == 'bottom-up':
120
- info = demo_runner.setup(api_key) + option_choice
121
  else:
122
  raise NotImplementedError
123
  return info, demo_runner
@@ -153,6 +157,7 @@ if __name__ == '__main__':
153
  with gr.Row():
154
  inp_api_key = gr.Textbox(label='OpenAI API Key (this is not stored anywhere)', lines=1)
155
 
 
156
  option_choice = gr.Radio(["bottom-up", "top-down"], label="Which mode?", interactive=True)
157
  inp_instruction = gr.Textbox(label='Target Task Name (if top-down)', lines=1)
158
  info_setup = gr.Markdown(label='Setup Info')
@@ -169,7 +174,7 @@ if __name__ == '__main__':
169
  video_run = gr.Video(label='Video of Last Instruction', autoplay=True)
170
  btn_setup.click(
171
  setup,
172
- inputs=[inp_api_key, option_choice, inp_instruction],
173
  outputs=[info_setup, state]
174
  )
175
  btn_run.click(
 
33
  hydra.initialize(version_base="1.2", config_path='cliport/cfg')
34
  self._cfg = hydra.compose(config_name="data")
35
 
36
+ def setup(self, api_key, model_choice):
37
  cfg = self._cfg
38
+ cfg['gpt_model'] = model_choice
39
  openai.api_key = api_key
40
  cfg['model_output_dir'] = 'temp'
41
  cfg['prompt_folder'] = 'bottomup_task_generation_prompt'
42
  set_gpt_model(cfg['gpt_model'])
43
+ cfg['load_memory'] = False
44
  cfg['use_template'] = True
45
+ cfg['task_description_candidate_num'] = 2
46
  cfg['record']['save_video'] = True
47
 
48
  print("cfg = ", cfg)
 
55
 
56
  return info
57
 
58
+ def setup_top_down(self, api_key, target_task_name, model_choice):
59
  cfg = self._cfg
60
+ cfg['gpt_model'] = model_choice
61
  openai.api_key = api_key
62
  cfg['model_output_dir'] = 'temp'
63
  cfg['prompt_folder'] = 'topdown_task_generation_prompt'
 
107
  print("run example cost = ", t2 - t1, " s")
108
 
109
 
110
+ def setup(api_key, option_choice, model_choice, target_task_name):
111
  print(option_choice)
112
  if not api_key:
113
  return 'Please enter your OpenAI API key!', None
114
 
115
+ if model_choice is None:
116
+ return 'Please choose the model!', None
117
  if option_choice is None:
118
  return 'Please choose the mode!', None
119
  demo_runner = DemoRunner()
120
 
121
  if option_choice == 'top-down':
122
+ info = demo_runner.setup_top_down(api_key, target_task_name, model_choice) + option_choice
123
  elif option_choice == 'bottom-up':
124
+ info = demo_runner.setup(api_key, model_choice) + option_choice
125
  else:
126
  raise NotImplementedError
127
  return info, demo_runner
 
157
  with gr.Row():
158
  inp_api_key = gr.Textbox(label='OpenAI API Key (this is not stored anywhere)', lines=1)
159
 
160
+ model_choice = gr.Radio(["gpt-3.5-turbo-16k", "gpt-4"], label="Which model?", interactive=True)
161
  option_choice = gr.Radio(["bottom-up", "top-down"], label="Which mode?", interactive=True)
162
  inp_instruction = gr.Textbox(label='Target Task Name (if top-down)', lines=1)
163
  info_setup = gr.Markdown(label='Setup Info')
 
174
  video_run = gr.Video(label='Video of Last Instruction', autoplay=True)
175
  btn_setup.click(
176
  setup,
177
+ inputs=[inp_api_key, option_choice, model_choice, inp_instruction],
178
  outputs=[info_setup, state]
179
  )
180
  btn_run.click(
cliport/environments/environment.py CHANGED
@@ -76,7 +76,6 @@ class Environment(gym.Env):
76
  self.position_bounds = gym.spaces.Box(
77
  low=np.array([0.25, -0.5, 0.], dtype=np.float32),
78
  high=np.array([0.75, 0.5, 0.28], dtype=np.float32),
79
- shape=(3,),
80
  dtype=np.float32)
81
  self.bounds = np.array([[0.25, 0.75], [-0.5, 0.5], [0, 0.3]])
82
 
 
76
  self.position_bounds = gym.spaces.Box(
77
  low=np.array([0.25, -0.5, 0.], dtype=np.float32),
78
  high=np.array([0.75, 0.5, 0.28], dtype=np.float32),
 
79
  dtype=np.float32)
80
  self.bounds = np.array([[0.25, 0.75], [-0.5, 0.5], [0, 0.3]])
81
 
gensim/agent.py CHANGED
@@ -125,7 +125,7 @@ class Agent:
125
  code_reference_cmd = extract_list(res, prefix='code_reference')
126
  exec(code_reference_cmd, globals())
127
  task_code_reference_replace_prompt = ''
128
- for key in code_reference:
129
  if key in self.memory.online_code_buffer:
130
  task_code_reference_replace_prompt += f'```\n{self.memory.online_code_buffer[key]}\n```\n\n'
131
  else:
 
125
  code_reference_cmd = extract_list(res, prefix='code_reference')
126
  exec(code_reference_cmd, globals())
127
  task_code_reference_replace_prompt = ''
128
+ for key in code_reference_cmd:
129
  if key in self.memory.online_code_buffer:
130
  task_code_reference_replace_prompt += f'```\n{self.memory.online_code_buffer[key]}\n```\n\n'
131
  else:
temp/BuildWheel_error.txt CHANGED
@@ -1,4 +1,10 @@
1
  Traceback (most recent call last):
2
- File "/home/baochen/Desktop/projects/GPT-CLIPort/gensim/sim_runner.py", line 339, in simulate_task
3
- yield "Task Generated ==> Asset Generated ==> API Reviewed ==> Error Reviewed ==> Code Generated ==> Simulation Running completed", self.generated_code, env.video_path
4
- AttributeError: 'Environment' object has no attribute 'video_path'
 
 
 
 
 
 
 
1
  Traceback (most recent call last):
2
+ File "/home/baochen/Desktop/projects/GPT-CLIPort/gensim/sim_runner.py", line 273, in simulate_task
3
+ task, dataset, env, expert = self.setup_env()
4
+ File "/home/baochen/Desktop/projects/GPT-CLIPort/gensim/sim_runner.py", line 199, in setup_env
5
+ env = Environment(
6
+ File "/home/baochen/Desktop/projects/GPT-CLIPort/cliport/environments/environment.py", line 76, in __init__
7
+ self.position_bounds = gym.spaces.Box(
8
+ File "/home/baochen/anaconda3/envs/Metaworld/lib/python3.8/site-packages/gym/spaces/box.py", line 33, in __init__
9
+ assert np.isscalar(low) and np.isscalar(high), 'box requires scalar bounds. '
10
+ AssertionError: box requires scalar bounds.