streetyogi commited on
Commit
12a9883
·
1 Parent(s): d358457

Update inference_server.py

Browse files
Files changed (1) hide show
  1. inference_server.py +7 -2
inference_server.py CHANGED
@@ -16,8 +16,13 @@ model.eval()
16
  # Load the BERT tokenizer
17
  tokenizer = transformers.BertTokenizer.from_pretrained('bert-base-cased')
18
  def predict(input_text: str):
19
- # Add the new input string to the set of strings
20
- strings.add(input_text)
 
 
 
 
 
21
  # Convert the input strings to input tensors for the BERT LM
22
  input_tensors = tokenizer.batch_encode_plus(list(strings), max_length=512,
23
  pad_to_max_length=True, return_tensors='pt')
 
16
  # Load the BERT tokenizer
17
  tokenizer = transformers.BertTokenizer.from_pretrained('bert-base-cased')
18
  def predict(input_text: str):
19
+ # Add the new input string to the file
20
+ with open('strings.txt','a') as f:
21
+ f.write(input_text + '\n')
22
+
23
+ # Read all the strings from the file
24
+ with open('strings.txt', 'r') as f:
25
+ strings = set(f.read().splitlines())
26
  # Convert the input strings to input tensors for the BERT LM
27
  input_tensors = tokenizer.batch_encode_plus(list(strings), max_length=512,
28
  pad_to_max_length=True, return_tensors='pt')