EXTRACTOBJECTS Procedure

Example 7.3 Visualize Detections in YOLO Format

(View the complete code for this example.)

This example shows how to use the EXTRACTOBJECTS procedure to visualize object detections that are provided in YOLO format. For more information about annotation formats, see the section Supported Image Annotation Formats.

The following PROC FEDSQL statement adds the object detections in YOLO format to the image table. It is assumed that the input image is loaded in the mylib.images table.

proc fedsql sessref=mysess;
   create table yolo_annotations as
   select
      *,
      2 as "_nObjects_",

      'object1' as "_Object0_",
      0.2343 as "_Object0_x", 0.2232 as "_Object0_y",
      0.4486 as "_Object0_width", 0.3437 as "_Object0_height",

      'object2' as "_Object1_",
      0.6473 as "_Object1_x", 0.4241 as "_Object1_y",
      0.4397 as "_Object1_width", 0.3281 as "_Object1_height"
   from
      images;
quit;

Note: These statements create the mylib.yolo_annotations table by using the image binaries and metadata from the mylib.images table and adding annotation variables in YOLO format. Ensure that the following variables are specified for each detected object in the mylib.yolo_annotations table, where N denotes the Nth detected object:

  • _ObjectN_

  • _ObjectN_x

  • _ObjectN_y

  • _ObjectN_width

  • _ObjectN_height

The following PROC PRINT statement displays the mylib.yolo_annotations table, which is generated by the previous statements:

proc print data=mylib.yolo_annotations;
run;

Output 7.3.1 shows the mylib.yolo_annotations table.

Output 7.3.1: The mylib.yolo_annotations Table

Obs_width__height__image__size__path__type__id__nObjects__Object0__Object0_x_Object0_y_Object0_width_Object0_height_Object1__Object1_x_Object1_y_Object1_width_Object1_height
1448448...457024/path/to/birds.pngpng12object10.23430.22320.44860.3437object20.64730.42410.43970.3281


The following statements highlight the two object detections in the input image by using the annotations that are provided in YOLO format. The resulting table, mylib.objects, contains images that have visualizations.

proc extractobjects data=mylib.yolo_annotations
   coordinateformat=yolo maxobjects=2 method=highlight;
   output out=mylib.objects;
run;

Output 7.3.2 shows the output image with two extracted objects.

Output 7.3.2: Visualization of Object Detections

Visualization of Object Detections


Last updated: March 26, 2026