Zhibinhong commited on
Commit
5b13b85
1 Parent(s): 89e197c

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +8 -6
handler.py CHANGED
@@ -29,14 +29,16 @@ class EndpointHandler():
29
  replacement=texts[1]
30
  if replacement=="":
31
  img=self.model.inference_remove(raw_image,target)
32
- img_data=img.tobytes()
33
- img_base64=base64.b64encode(img_data).decode('utf-8')
34
- return {'image':img_base64}
 
35
  else:
36
  img=self.model.inference_replace_sam(raw_image,target,replacement)
37
- img_data=img.tobytes()
38
- img_base64=base64.b64encode(img_data).decode('utf-8')
39
- return {'image':img_base64}
 
40
 
41
 
42
  if __name__=="__main__":
 
29
  replacement=texts[1]
30
  if replacement=="":
31
  img=self.model.inference_remove(raw_image,target)
32
+ img.save("./1.png")
33
+ with open('./1.png','rb') as img_file:
34
+ encoded_string = base64.b64encode(img_file.read()).decode('utf-8')
35
+ return {'image':encoded_string}
36
  else:
37
  img=self.model.inference_replace_sam(raw_image,target,replacement)
38
+ img.save("./1.png")
39
+ with open('./1.png','rb') as img_file:
40
+ encoded_string = base64.b64encode(img_file.read()).decode('utf-8')
41
+ return {'image':encoded_string}
42
 
43
 
44
  if __name__=="__main__":