|
|
from autodistill_grounded_sam import GroundedSAM |
|
|
from autodistill.detection import CaptionOntology |
|
|
from autodistill.utils import plot |
|
|
import cv2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes = ["crack"] |
|
|
|
|
|
base_model = GroundedSAM(ontology=CaptionOntology({"crack": "crack"})) |
|
|
|
|
|
results = base_model.predict("crack.png") |
|
|
|
|
|
image = cv2.imread("crack.png") |
|
|
|
|
|
|
|
|
print("Image shape:", image.shape) |
|
|
print("Image dtype:", image.dtype) |
|
|
print("Image size:", image.size) |
|
|
|
|
|
|
|
|
plot( |
|
|
image=image, |
|
|
detections=results, |
|
|
classes=[classes[i] for i in results.class_id], |
|
|
) |
|
|
|
|
|
|
|
|
print(results) |
|
|
|