|
624 | 624 | "source": [ |
625 | 625 | "import supervision as sv\n", |
626 | 626 | "\n", |
627 | | - "ds_test = sv.DetectionDataset.from_coco(\n", |
| 627 | + "ds = sv.DetectionDataset.from_coco(\n", |
628 | 628 | " images_directory_path=f\"{dataset.location}/test\",\n", |
629 | 629 | " annotations_path=f\"{dataset.location}/test/_annotations.coco.json\",\n", |
630 | 630 | " force_masks=True\n", |
|
659 | 659 | "import matplotlib.pyplot as plt\n", |
660 | 660 | "\n", |
661 | 661 | "N = 16\n", |
662 | | - "L = len(ds_test)\n", |
| 662 | + "L = len(ds)\n", |
663 | 663 | "\n", |
664 | 664 | "annotated_images = []\n", |
665 | 665 | "\n", |
666 | 666 | "for i in random.sample(range(L), N):\n", |
667 | | - " path, _, annotations = ds_test[i]\n", |
| 667 | + " path, _, annotations = ds[i]\n", |
668 | 668 | " image = Image.open(path)\n", |
669 | 669 | " detections = model.predict(image, threshold=0.5)\n", |
670 | | - " annotated_image = annotate(image, detections, classes={i: class_name for i, class_name in enumerate(ds_test.classes)})\n", |
| 670 | + " annotated_image = annotate(image, detections, classes={i: class_name for i, class_name in enumerate(ds.classes)})\n", |
671 | 671 | " annotated_images.append(annotated_image)\n", |
672 | 672 | "\n", |
673 | 673 | "fig, axes = plt.subplots(4, 4, figsize=(12, 12))\n", |
|
734 | 734 | "import matplotlib.pyplot as plt\n", |
735 | 735 | "\n", |
736 | 736 | "N = 16\n", |
737 | | - "L = len(ds_test)\n", |
| 737 | + "L = len(ds)\n", |
738 | 738 | "\n", |
739 | 739 | "annotated_images = []\n", |
740 | 740 | "\n", |
741 | 741 | "for i in random.sample(range(L), N):\n", |
742 | | - " path, _, annotations = ds_test[i]\n", |
| 742 | + " path, _, annotations = ds[i]\n", |
743 | 743 | " image = Image.open(path)\n", |
744 | 744 | " result = model_rf.infer(image, confidence=0.5)[0]\n", |
745 | 745 | " detections = sv.Detections.from_inference(result)\n", |
746 | | - " annotated_image = annotate(image, detections, classes={i: class_name for i, class_name in enumerate(ds_test.classes)})\n", |
| 746 | + " annotated_image = annotate(image, detections, classes={i: class_name for i, class_name in enumerate(ds.classes)})\n", |
747 | 747 | " annotated_images.append(annotated_image)\n", |
748 | 748 | "\n", |
749 | 749 | "fig, axes = plt.subplots(4, 4, figsize=(12, 12))\n", |
|
0 commit comments