TongkunGuan commited on
Commit
8b7820a
·
verified ·
1 Parent(s): 2e3a2cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -63,8 +63,13 @@ def process_image(model, tokenizer, transform, device, check_type, image, text):
63
  target_ratio = (1, 1)
64
 
65
  # 文本处理
66
- text += ' '
67
- input_ids = tokenizer(text)['input_ids'][1:]
 
 
 
 
 
68
  input_ids = torch.tensor(input_ids, device=device)
69
 
70
  # 获取嵌入
 
63
  target_ratio = (1, 1)
64
 
65
  # 文本处理
66
+ text_input = text
67
+
68
+ if text_input[0] in '!"#$%&\'()*+,-./0123456789:;<=>?@^_{|}~0123456789':
69
+ input_ids = tokenizer(text_input)['input_ids'][1:]
70
+ else:
71
+ input_ids = tokenizer(' '+text_input)['input_ids'][1:]
72
+
73
  input_ids = torch.tensor(input_ids, device=device)
74
 
75
  # 获取嵌入