(image, mask, color, alpha_transparency=0.5)
| 42 | |
| 43 | #Overlay mask with transparency on top of the image. |
| 44 | def overlay(image, mask, color, alpha_transparency=0.5): |
| 45 | for channel in range(3): |
| 46 | image[:, :, channel] = np.where(mask == 1, |
| 47 | image[:, :, channel] * |
| 48 | (1 - alpha_transparency) + alpha_transparency * color[channel] * 255, |
| 49 | image[:, :, channel]) |
| 50 | return image |
| 51 | |
| 52 | def visualize_detections(image_path, output_path, detections, labels=[], iou_threshold=0.5): |
| 53 | image = Image.open(image_path).convert(mode='RGB') |
no outgoing calls
no test coverage detected