Open rkuo2000 opened 10 months ago
i am also facing this problem, how to solve it?
You can check the output of your code to see if there are some objects to be detected or not
@rentainhe
I only modify the following two lines in grounded_sam_simple_demo.py
SOURCE_IMAGE_PATH = "./assets/demo2.jpg"
CLASSES = ["The running dog"]
and print the detection results as such:
# print detections
for d in detections:
print(d)
which gives me
(array([ 801.4983, 516.0155, 1788.2068, 991.4297], dtype=float32), None, 0.89449936, None, None)
Why is it giving None?
This problem has been mentioned here as well https://github.com/IDEA-Research/Grounded-Segment-Anything/issues/371, https://github.com/IDEA-Research/Grounded-Segment-Anything/issues/244,
What should I do to resolve this problem?
You can hack in the code and check the output name to see if it is matched with the running dog
, this may be due to that grounding dino will only output the text whose confidence is larger than the text threshold, then the visualization tool will match the name with the input label to generate the final visualization file. I think there're something wrong with the name matching part here: https://github.com/IDEA-Research/Grounded-Segment-Anything/blob/c643397a5f641eb3f6450e8fd42c91ec7833031e/GroundingDINO/groundingdino/util/inference.py#L249
I've fixed some corner cases in this part, I may still miss some cases
@rentainhe which commit has the fix?
python grounded_sam_simple_demo.py
File "/kaggle/working/Grounded-Segment-Anything/grounded_sam_simple_demo.py", line 51, in
labels = [
File "/kaggle/working/Grounded-Segment-Anything/grounded_sam_simple_demo.py", line 52, in
f"{CLASSES[class_id]} {confidence:0.2f}"
TypeError: list indices must be integers or slices, not NoneType