You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the Autodistill issues and found no similar bug report.
Bug
Description:
While using the base model in Autodistill for image labeling with SAHI, passing a file path (string) instead of an image object to Supervision InferenceSlicer results in an AttributeError. This issue occurs in the label method of DetectionBaseModel when sahi is set to True.
Error Stack Trace:
{
"name": "AttributeError",
"message": "'str' object has no attribute 'shape'",
"stack": "---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[2], line 6
2 from autodistill.detection import CaptionOntology
4 base_model = GroundingDINO(ontology=CaptionOntology({\"milk bottle\": \"bottle\", \"milk bottle cap\": \"bottle cap\"}))
----> 6 base_model.label(
7 input_folder=\"./images\",
8 output_folder=\"./dataset\",
9 sahi=True
10 )
File c:\\users\\tomsg\\work\\open-source\\autodistill\\autodistill\\autodistill\\detection\\detection_base_model.py:66, in DetectionBaseModel.label(self, input_folder, extension, output_folder, human_in_the_loop, roboflow_project, roboflow_tags, sahi)
63 images_map[f_path_short] = image.copy()
65 if sahi:
---> 66 detections = slicer(f_path)
67 else:
68 detections = self.predict(f_path)
File c:\\Users\\tomsg\\Work\\open-source\\autodistill\\.venv\\Lib\\site-packages\\supervision\\detection\\tools\\inference_slicer.py:98, in InferenceSlicer.__call__(self, image)
66 \"\"\"
67 Performs slicing-based inference on the provided image using the specified
68 callback.
(...)
95 ```
96 \"\"\"
97 detections_list = []
---> 98 resolution_wh = (image.shape[1], image.shape[0])
99 offsets = self._generate_offset(
100 resolution_wh=resolution_wh,
101 slice_wh=self.slice_wh,
102 overlap_ratio_wh=self.overlap_ratio_wh,
103 )
105 with ThreadPoolExecutor(max_workers=self.thread_workers) as executor:
AttributeError: 'str' object has no attribute 'shape'"
}
Environment
Autodistill: commit 0b90409 (built from source)
Supervision: 0.17.1
Python: 3.11.3
OS: Microsoft Windows 11 Pro for Workstations
Minimal Reproducible Example
Steps to Reproduce:
Initialize GroundingDINO with a custom ontology in Autodistill.
Call base_model.label with the sahi flag set to True.
Encounter AttributeError due to string input instead of image object.
I have a PR in the works to fix this bug. I will post here when the PR is merged and live in the autodistill package.
Please note that it will take a long time to run SAHI with Grounding DINO. This is because SAHI splits up an image into multiple frames and runs inference on each of them.
We recommend trying to run Grounding DINO without SAHI to label your images first. If you have a small dataset with a large number of small objects that Grounding DINO can identify, SAHI might be helpful!
Search before asking
Bug
Description:
While using the base model in Autodistill for image labeling with SAHI, passing a file path (string) instead of an image object to Supervision InferenceSlicer results in an AttributeError. This issue occurs in the label method of DetectionBaseModel when sahi is set to True.
Error Stack Trace:
Environment
0b90409
(built from source)Minimal Reproducible Example
Steps to Reproduce:
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: