chansung commited on
Commit
4c8e231
·
1 Parent(s): 299f5c7

update custom handler

Browse files
Files changed (2) hide show
  1. __pycache__/handler.cpython-38.pyc +0 -0
  2. handler.py +5 -1
__pycache__/handler.cpython-38.pyc CHANGED
Binary files a/__pycache__/handler.cpython-38.pyc and b/__pycache__/handler.cpython-38.pyc differ
 
handler.py CHANGED
@@ -1,4 +1,5 @@
1
  from typing import Dict, List, Any
 
2
  import base64
3
 
4
  import tensorflow as tf
@@ -12,8 +13,11 @@ class EndpointHandler():
12
  def __init__(self, path="", version="2"):
13
  self.MAX_PROMPT_LENGTH = 77
14
 
15
- self.tokenizer = SimpleTokenizer()
16
  self.text_encoder = self._instantiate_text_encoder(version)
 
 
 
 
17
  self.pos_ids = tf.convert_to_tensor([list(range(self.MAX_PROMPT_LENGTH))], dtype=tf.int32)
18
 
19
  def _instantiate_text_encoder(self, version: str):
 
1
  from typing import Dict, List, Any
2
+ import sys
3
  import base64
4
 
5
  import tensorflow as tf
 
13
  def __init__(self, path="", version="2"):
14
  self.MAX_PROMPT_LENGTH = 77
15
 
 
16
  self.text_encoder = self._instantiate_text_encoder(version)
17
+ if isinstance(self.text_encoder, str):
18
+ sys.exit(self.text_encoder)
19
+
20
+ self.tokenizer = SimpleTokenizer()
21
  self.pos_ids = tf.convert_to_tensor([list(range(self.MAX_PROMPT_LENGTH))], dtype=tf.int32)
22
 
23
  def _instantiate_text_encoder(self, version: str):