Haofei Yu commited on
Commit
db59335
1 Parent(s): d98f331

fix image processor bug (#24)

Browse files

* update UI

* support image processor bug

Files changed (2) hide show
  1. app.py +4 -0
  2. ctm/processors/processor_gpt4v.py +1 -1
app.py CHANGED
@@ -5,6 +5,9 @@ import gradio as gr
5
 
6
  sys.path.append("./ctm")
7
  from ctm.ctms.ctm_base import BaseConsciousnessTuringMachine
 
 
 
8
 
9
  ctm = BaseConsciousnessTuringMachine()
10
  ctm.add_supervisor("gpt4_supervisor")
@@ -105,6 +108,7 @@ def processor_tab():
105
 
106
 
107
  def forward(query, content, image, state):
 
108
  state["question"] = query
109
  ask_processors_output_info, state = ask_processors(
110
  query, content, image, state
 
5
 
6
  sys.path.append("./ctm")
7
  from ctm.ctms.ctm_base import BaseConsciousnessTuringMachine
8
+ from PIL import Image
9
+ import io
10
+ import base64
11
 
12
  ctm = BaseConsciousnessTuringMachine()
13
  ctm.add_supervisor("gpt4_supervisor")
 
108
 
109
 
110
  def forward(query, content, image, state):
111
+ image = convert_base64(image)
112
  state["question"] = query
113
  ask_processors_output_info, state = ask_processors(
114
  query, content, image, state
ctm/processors/processor_gpt4v.py CHANGED
@@ -57,7 +57,7 @@ class GPT4VProcessor(BaseProcessor):
57
  or "No instruction provided.",
58
  },
59
  ]
60
- if image:
61
  messages.append(
62
  {
63
  "type": "image_url",
 
57
  or "No instruction provided.",
58
  },
59
  ]
60
+ if image is not None:
61
  messages.append(
62
  {
63
  "type": "image_url",