(self, inputs)
| 1145 | "The input to this tool should be a comma separated string of two, " |
| 1146 | "representing the image_path, the text description of the object to be found") |
| 1147 | def inference(self, inputs): |
| 1148 | image_path, det_prompt = inputs.split(",") |
| 1149 | print(f"image_path={image_path}, text_prompt={det_prompt}") |
| 1150 | image_pil, image = self.load_image(image_path) |
| 1151 | |
| 1152 | boxes_filt, pred_phrases = self.get_grounding_boxes(image, det_prompt) |
| 1153 | |
| 1154 | size = image_pil.size |
| 1155 | pred_dict = { |
| 1156 | "boxes": boxes_filt, |
| 1157 | "size": [size[1], size[0]], # H,W |
| 1158 | "labels": pred_phrases,} |
| 1159 | |
| 1160 | image_with_box = self.plot_boxes_to_image(image_pil, pred_dict)[0] |
| 1161 | |
| 1162 | updated_image_path = get_new_image_name(image_path, func_name="detect-something") |
| 1163 | updated_image = image_with_box.resize(size) |
| 1164 | updated_image.save(updated_image_path) |
| 1165 | print( |
| 1166 | f"\nProcessed ObejectDetecting, Input Image: {image_path}, Object to be Detect {det_prompt}, " |
| 1167 | f"Output Image: {updated_image_path}") |
| 1168 | return updated_image_path |
| 1169 | |
| 1170 | |
| 1171 | class Inpainting: |
no test coverage detected