joonh-robotics commited on
Commit
1ee1b25
·
verified ·
1 Parent(s): 48b3e34

update files

Browse files
Files changed (2) hide show
  1. app.py +11 -7
  2. requirements.txt +3 -3
app.py CHANGED
@@ -12,7 +12,7 @@ model_status = "Model is not initialized."
12
 
13
  def initialize_model(api_key):
14
  global model, model_status
15
- if model is None: # Initialize the model only if it hasn't been already
16
  model = GPT4VisionClass(key=api_key, max_tokens=1024, temperature=0.9,
17
  gpt_model="gpt-4-vision-preview",
18
  role_msg="You are a helpful agent with vision capabilities; do not respond to objects not depicted in images.")
@@ -54,6 +54,9 @@ if __name__ == "__main__":
54
  }
55
 
56
  with gr.Blocks() as demo:
 
 
 
57
  ######## Introduction for the demo
58
  with gr.Column():
59
  gr.Markdown("""
@@ -70,14 +73,15 @@ if __name__ == "__main__":
70
  for category, scenarios in image_paths.items():
71
  with gr.Column():
72
  gr.Markdown(f"## {category}")
73
- with gr.Row(wrap=True):
74
  for scenario, img_path in scenarios.items():
75
- with gr.Column(layout='horizontal', variant='panel'):
76
- gr.Image(value=img_path, tool=None).style(width='33%', margin='5px')
77
- gr.Button(scenario, onclick=lambda x=scenario: scenario_button_clicked(x)).style(width='33%', margin='5px')
 
78
 
79
  ######## Input OpenAI API Key and display initialization result
80
- with gr.Row(): # Use gr.Row for horizontal layout
81
  # API Key Input
82
  with gr.Column():
83
  openai_gpt4_key = gr.Textbox(label="OpenAI GPT4 Key", type="password", placeholder="sk..",
@@ -92,7 +96,7 @@ if __name__ == "__main__":
92
  chatbot = gr.Chatbot(elem_id="chatbot")
93
  state = gr.State([])
94
  with gr.Row():
95
- query_text = gr.Textbox(show_label=False, placeholder="Enter text and press enter, or upload an image").style(container=False)
96
  query_text.submit(add_text, inputs=[state, query_text], outputs=[state, chatbot])
97
  query_text.submit(lambda: "", inputs=None, outputs=query_text)
98
 
 
12
 
13
  def initialize_model(api_key):
14
  global model, model_status
15
+ if model is None:
16
  model = GPT4VisionClass(key=api_key, max_tokens=1024, temperature=0.9,
17
  gpt_model="gpt-4-vision-preview",
18
  role_msg="You are a helpful agent with vision capabilities; do not respond to objects not depicted in images.")
 
54
  }
55
 
56
  with gr.Blocks() as demo:
57
+ scenario = "Example Scenario"
58
+ output_text = gr.Text(label="Click Result")
59
+
60
  ######## Introduction for the demo
61
  with gr.Column():
62
  gr.Markdown("""
 
73
  for category, scenarios in image_paths.items():
74
  with gr.Column():
75
  gr.Markdown(f"## {category}")
76
+ with gr.Row():
77
  for scenario, img_path in scenarios.items():
78
+ with gr.Column(scale=2):
79
+ gr.Image(value=img_path)
80
+ scenario_button = gr.Button(scenario)
81
+ scenario_button.click(fn=lambda x=scenario: scenario_button_clicked(x), inputs=[], outputs=[output_text])
82
 
83
  ######## Input OpenAI API Key and display initialization result
84
+ with gr.Row():
85
  # API Key Input
86
  with gr.Column():
87
  openai_gpt4_key = gr.Textbox(label="OpenAI GPT4 Key", type="password", placeholder="sk..",
 
96
  chatbot = gr.Chatbot(elem_id="chatbot")
97
  state = gr.State([])
98
  with gr.Row():
99
+ query_text = gr.Textbox(show_label=False, placeholder="Enter text and press enter, or upload an image")
100
  query_text.submit(add_text, inputs=[state, query_text], outputs=[state, chatbot])
101
  query_text.submit(lambda: "", inputs=None, outputs=query_text)
102
 
requirements.txt CHANGED
@@ -1,6 +1,6 @@
1
- gradio==3.42.0
2
- gradio_client==0.5.0
3
- openai==1.3.8
4
  matplotlib
5
  numpy
6
  Pillow
 
1
+ gradio
2
+ gradio_client
3
+ openai
4
  matplotlib
5
  numpy
6
  Pillow