Shanshan Wang commited on
Commit
d6bfd67
1 Parent(s): 2d6f1c5

use model.ocr for 0.8b model

Browse files
Files changed (1) hide show
  1. app.py +44 -20
app.py CHANGED
@@ -125,15 +125,28 @@ def inference(image_input,
125
  )
126
 
127
  # Call model.chat with history
128
- response_text, new_state = model.chat(
129
- tokenizer,
130
- image_input,
131
- user_message,
132
- max_tiles = int(tile_num),
133
- generation_config=generation_config,
134
- history=state,
135
- return_history=True
136
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
137
 
138
  # update the satet with new_state
139
  state = new_state
@@ -197,17 +210,28 @@ def regenerate_response(chatbot,
197
  top_p= float(top_p),
198
  )
199
 
200
-
201
  # Regenerate the response
202
- response_text, new_state = model.chat(
203
- tokenizer,
204
- image_input,
205
- last_user_message,
206
- max_tiles = int(tile_num),
207
- generation_config=generation_config,
208
- history=state, # Exclude last assistant's response
209
- return_history=True
210
- )
 
 
 
 
 
 
 
 
 
 
 
211
 
212
  # Update the state with new_state
213
  state = new_state
@@ -304,7 +328,7 @@ with gr.Blocks() as demo:
304
  interactive=True,
305
  label="Top P")
306
  max_new_tokens_input = gr.Slider(
307
- minimum=0,
308
  maximum=4096,
309
  step=64,
310
  value=1024,
 
125
  )
126
 
127
  # Call model.chat with history
128
+ if '2b' in model_name.lower():
129
+ response_text, new_state = model.chat(
130
+ tokenizer,
131
+ image_input,
132
+ user_message,
133
+ max_tiles = int(tile_num),
134
+ generation_config=generation_config,
135
+ history=state,
136
+ return_history=True
137
+ )
138
+
139
+
140
+ if '0.8b' in model_name.lower():
141
+ response_text, new_state = model.ocr(
142
+ tokenizer,
143
+ image_input,
144
+ user_message,
145
+ max_tiles = int(tile_num),
146
+ generation_config=generation_config,
147
+ history=state,
148
+ return_history=True
149
+ )
150
 
151
  # update the satet with new_state
152
  state = new_state
 
210
  top_p= float(top_p),
211
  )
212
 
213
+
214
  # Regenerate the response
215
+ if '2b' in model_name.lower():
216
+ response_text, new_state = model.chat(
217
+ tokenizer,
218
+ image_input,
219
+ last_user_message,
220
+ max_tiles = int(tile_num),
221
+ generation_config=generation_config,
222
+ history=state, # Exclude last assistant's response
223
+ return_history=True
224
+ )
225
+ if '0.8b' in model_name.lower():
226
+ response_text, new_state = model.ocr(
227
+ tokenizer,
228
+ image_input,
229
+ last_user_message,
230
+ max_tiles = int(tile_num),
231
+ generation_config=generation_config,
232
+ history=state, # Exclude last assistant's response
233
+ return_history=True
234
+ )
235
 
236
  # Update the state with new_state
237
  state = new_state
 
328
  interactive=True,
329
  label="Top P")
330
  max_new_tokens_input = gr.Slider(
331
+ minimum=64,
332
  maximum=4096,
333
  step=64,
334
  value=1024,