MCPcopy Create free account
hub / github.com/UX-Decoder/Semantic-SAM / interactive_infer_image

Function interactive_infer_image

tasks/interactive_idino_m2m_auto.py:21–44  ·  view source on GitHub ↗
(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)

Source from the content-addressed store, hash-verified

19metadata = MetadataCatalog.get('coco_2017_train_panoptic')
20
21def 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
47def remove_small_regions(

Callers

nothing calls this directly

Calls 3

generateMethod · 0.95
show_annsFunction · 0.85

Tested by

no test coverage detected