(model, image,level,all_classes,all_parts, thresh,text_size,hole_scale,island_scale,semantic, refimg=None, reftxt=None, audio_pth=None, video_pth=None)
| 19 | metadata = MetadataCatalog.get('coco_2017_train_panoptic') |
| 20 | |
| 21 | def interactive_infer_image(model, image,level,all_classes,all_parts, thresh,text_size,hole_scale,island_scale,semantic, refimg=None, reftxt=None, audio_pth=None, video_pth=None): |
| 22 | t = [] |
| 23 | t.append(transforms.Resize(int(text_size), interpolation=Image.BICUBIC)) |
| 24 | transform1 = transforms.Compose(t) |
| 25 | image_ori = transform1(image) |
| 26 | |
| 27 | image_ori = np.asarray(image_ori) |
| 28 | images = torch.from_numpy(image_ori.copy()).permute(2,0,1).cuda() |
| 29 | |
| 30 | mask_generator = SemanticSamAutomaticMaskGenerator(model,points_per_side=32, |
| 31 | pred_iou_thresh=0.88, |
| 32 | stability_score_thresh=0.92, |
| 33 | min_mask_region_area=10, |
| 34 | level=level, |
| 35 | ) |
| 36 | |
| 37 | outputs = mask_generator.generate(images) |
| 38 | |
| 39 | fig=plt.figure(figsize=(10, 10)) |
| 40 | plt.imshow(image_ori) |
| 41 | show_anns(outputs) |
| 42 | fig.canvas.draw() |
| 43 | im=Image.frombytes('RGB', fig.canvas.get_width_height(), fig.canvas.tostring_rgb()) |
| 44 | return im |
| 45 | |
| 46 | |
| 47 | def remove_small_regions( |
nothing calls this directly
no test coverage detected