From bc586562b5a242ff3406cebd005d0a9b8d0afe81 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 12:14:41 +0000 Subject: [PATCH] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto=20form?= =?UTF-8?q?at=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/how_to/detect_and_annotate.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/how_to/detect_and_annotate.md b/docs/how_to/detect_and_annotate.md index b068a923..96073044 100644 --- a/docs/how_to/detect_and_annotate.md +++ b/docs/how_to/detect_and_annotate.md @@ -4,17 +4,17 @@ comments: true # Detect and Annotate -Supervision provides a seamless process for annotating predictions generated by various -object detection and segmentation models. This guide shows how to perform inference -with the [Inference](https://github.com/roboflow/inference), -[Ultralytics](https://github.com/ultralytics/ultralytics) or +Supervision provides a seamless process for annotating predictions generated by various +object detection and segmentation models. This guide shows how to perform inference +with the [Inference](https://github.com/roboflow/inference), +[Ultralytics](https://github.com/ultralytics/ultralytics) or [Transformers](https://github.com/huggingface/transformers) packages. Following this, -you'll learn how to import these predictions into Supervision and use them to annotate +you'll learn how to import these predictions into Supervision and use them to annotate source image. ## Run Inference -First, you'll need to obtain predictions from your object detection or segmentation +First, you'll need to obtain predictions from your object detection or segmentation model. === "Inference" @@ -51,10 +51,10 @@ model. image = Image.open() inputs = processor(images=image, return_tensors="pt") - + with torch.no_grad(): outputs = model(**inputs) - + width, height = image.size target_size = torch.tensor([[height, width]]) results = processor.post_process_object_detection( @@ -110,10 +110,10 @@ Now that we have predictions from a model, we can load them into Supervision. image = Image.open() inputs = processor(images=image, return_tensors="pt") - + with torch.no_grad(): outputs = model(**inputs) - + width, height = image.size target_size = torch.tensor([[height, width]]) results = processor.post_process_object_detection( @@ -188,16 +188,16 @@ Finally, we can annotate the image with the predictions. Since we are working wi image = Image.open() inputs = processor(images=image, return_tensors="pt") - + with torch.no_grad(): outputs = model(**inputs) - + width, height = image.size target_size = torch.tensor([[height, width]]) results = processor.post_process_object_detection( outputs=outputs, target_sizes=target_size)[0] detections = sv.Detections.from_transformers(results) - + bounding_box_annotator = sv.BoundingBoxAnnotator() label_annotator = sv.LabelAnnotator() @@ -271,4 +271,4 @@ Finally, we can annotate the image with the predictions. Since we are working wi ## Annotate Image with Segmentations -If you are running the segmentation model [`sv.MaskAnnotator`](annotators/#supervision.annotators.core.MaskAnnotator) is a drop-in replacement for [`sv.BoundingBoxAnnotator`](annotators/#supervision.annotators.core.BoundingBoxAnnotator) that will allow you to draw masks instead of boxes. \ No newline at end of file +If you are running the segmentation model [`sv.MaskAnnotator`](annotators/#supervision.annotators.core.MaskAnnotator) is a drop-in replacement for [`sv.BoundingBoxAnnotator`](annotators/#supervision.annotators.core.BoundingBoxAnnotator) that will allow you to draw masks instead of boxes.