chansung commited on
Commit
dfec646
·
1 Parent(s): 2ba17e5

add custom handler

Browse files
Files changed (2) hide show
  1. __pycache__/handler.cpython-38.pyc +0 -0
  2. handler.py +4 -5
__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
@@ -56,18 +56,17 @@ class EndpointHandler():
56
  def __call__(self, data: Dict[str, Any]) -> str:
57
  # get inputs
58
  tmp_data = data.pop("inputs", data)
 
59
 
60
  context = base64.b64decode(tmp_data[0])
61
  context = np.frombuffer(context, dtype="float32")
62
- context = np.reshape(context, (1, 77, 768))
63
 
64
  unconditional_context = base64.b64decode(tmp_data[1])
65
  unconditional_context = np.frombuffer(unconditional_context, dtype="float32")
66
- unconditional_context = np.reshape(unconditional_context, (1, 77, 768))
67
-
68
- batch_size = data.pop("batch_size", 1)
69
 
70
- num_steps = data.pop("num_steps", 50)
71
  unconditional_guidance_scale = data.pop("unconditional_guidance_scale", 7.5)
72
 
73
  latent = self._get_initial_diffusion_noise(batch_size, self.seed)
 
56
  def __call__(self, data: Dict[str, Any]) -> str:
57
  # get inputs
58
  tmp_data = data.pop("inputs", data)
59
+ batch_size = data.pop("batch_size", 1)
60
 
61
  context = base64.b64decode(tmp_data[0])
62
  context = np.frombuffer(context, dtype="float32")
63
+ context = np.reshape(context, (batch_size, 77, 768))
64
 
65
  unconditional_context = base64.b64decode(tmp_data[1])
66
  unconditional_context = np.frombuffer(unconditional_context, dtype="float32")
67
+ unconditional_context = np.reshape(unconditional_context, (batch_size, 77, 768))
 
 
68
 
69
+ num_steps = data.pop("num_steps", 25)
70
  unconditional_guidance_scale = data.pop("unconditional_guidance_scale", 7.5)
71
 
72
  latent = self._get_initial_diffusion_noise(batch_size, self.seed)