given a image, return the picture only contains the extracted main object
(self, image_path)
| 1429 | "the input should be a string image_path" |
| 1430 | ) |
| 1431 | def inference(self, image_path): |
| 1432 | ''' |
| 1433 | given a image, return the picture only contains the extracted main object |
| 1434 | ''' |
| 1435 | updated_image_path = None |
| 1436 | |
| 1437 | mask = self.get_mask(image_path) |
| 1438 | |
| 1439 | image = Image.open(image_path) |
| 1440 | mask = Image.fromarray(mask) |
| 1441 | image.putalpha(mask) |
| 1442 | |
| 1443 | updated_image_path = get_new_image_name(image_path, func_name="detect-something") |
| 1444 | image.save(updated_image_path) |
| 1445 | |
| 1446 | return updated_image_path |
| 1447 | |
| 1448 | def get_mask(self, image_path): |
| 1449 | ''' |
nothing calls this directly
no test coverage detected