nikravan commited on
Commit
69acb26
·
verified ·
1 Parent(s): dba52b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -36,8 +36,11 @@ def generate_response(message, history):
36
  inputs["token_type_ids"] = torch.ones_like(inputs["input_ids"])
37
 
38
  with torch.no_grad():
39
- out = model.generate(**inputs, max_new_tokens=256, do_sample=False)
40
- return tokenizer.decode(out[0], skip_special_tokens=False)
 
 
 
41
  chatbot = gr.ChatInterface(
42
  fn=generate_response,
43
  title="Simple ZeroGPU Chatbot",
 
36
  inputs["token_type_ids"] = torch.ones_like(inputs["input_ids"])
37
 
38
  with torch.no_grad():
39
+ text = model.generate(**inputs, max_new_tokens=256, do_sample=False)
40
+ start = text.find('<|object_ref_end|>') + len('<|object_ref_end|>')
41
+ end = text.find('<|box_end|>')
42
+ result = text[start:end]
43
+ return tokenizer.decode(result, skip_special_tokens=False)
44
  chatbot = gr.ChatInterface(
45
  fn=generate_response,
46
  title="Simple ZeroGPU Chatbot",