Zhibinhong
commited on
Commit
•
5b13b85
1
Parent(s):
89e197c
Update handler.py
Browse files- 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 |
-
|
33 |
-
|
34 |
-
|
|
|
35 |
else:
|
36 |
img=self.model.inference_replace_sam(raw_image,target,replacement)
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
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__":
|