Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xyxy coordinates are not absolute #5

Open
egnerfl opened this issue Feb 7, 2024 · 1 comment
Open

xyxy coordinates are not absolute #5

egnerfl opened this issue Feb 7, 2024 · 1 comment

Comments

@egnerfl
Copy link

egnerfl commented Feb 7, 2024

First of all, thanks for creating the repo!

While playing around with autodistill I noticed that llava always returns relative coordinates which can't be displayed by supervision out of the box. I guess these just need to be converted to absolute values.

This should do the job:

image = Image.open(SAMPLE_IMAGE)

# # Transform detection bounding boxes from percentage to absolute coordinates
# for detection in results.xyxy:
#     detection[0] *= image.width
#     detection[1] *= image.height
#     detection[2] *= image.width
#     detection[3] *= image.height
@Samuel5106
Copy link

First of all, thanks for creating the repo!

While playing around with autodistill I noticed that llava always returns relative coordinates which can't be displayed by supervision out of the box. I guess these just need to be converted to absolute values.

This should do the job:

image = Image.open(SAMPLE_IMAGE)

# # Transform detection bounding boxes from percentage to absolute coordinates
# for detection in results.xyxy:
#     detection[0] *= image.width
#     detection[1] *= image.height
#     detection[2] *= image.width
#     detection[3] *= image.height

Hi, @egnerfl is the llava (autodstill code is working) I am facing an error while I am passing the images folder can you help me with this?

AttributeError Traceback (most recent call last)
File ~/.pyenv/versions/3.8.0/lib/python3.8/site-packages/PIL/Image.py:3222, in open(fp, mode, formats)
3221 try:
-> 3222 fp.seek(0)
3223 except (AttributeError, io.UnsupportedOperation):

AttributeError: 'numpy.ndarray' object has no attribute 'seek'

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last)
Cell In[2], line 18
8 base_model = LLaVA(
9 ontology=CaptionOntology(
10 {
(...)
13 )
14 )
16 # base_model.label("/home/aiteam/data1/samuel/test_images_for_each_model/may2_test_images_for_ilava", extension=".jpg")
---> 18 base_model.label(input_folder="/home/aiteam/data1/samuel/test_images_for_each_model/may2_test_images_for_ilava", extension=".jpg")

File ~/.pyenv/versions/3.8.0/lib/python3.8/site-packages/autodistill/detection/detection_base_model.py:99, in DetectionBaseModel.label(self, input_folder, extension, output_folder, human_in_the_loop, roboflow_project, roboflow_tags, sahi, record_confidence, nms_settings)
97 detections = slicer(image)
98 else:
---> 99 detections = self.predict(image)
101 if nms_settings == NmsSetting.CLASS_SPECIFIC:
102 detections = detections.with_nms()

File ~/.pyenv/versions/3.8.0/lib/python3.8/site-packages/autodistill_llava/model.py:97, in LLaVA.predict(self, input)
96 def predict(self, input: str) -> sv.Detections:
---> 97 image = Image.open(input)
99 # image = Image.fromarray(input)
101 ImageInfo = namedtuple('ImageInfo', ['image_aspect_ratio'])

File ~/.pyenv/versions/3.8.0/lib/python3.8/site-packages/PIL/Image.py:3224, in open(fp, mode, formats)
3222 fp.seek(0)
3223 except (AttributeError, io.UnsupportedOperation):
-> 3224 fp = io.BytesIO(fp.read())
3225 exclusive_fp = True
3227 prefix = fp.read(16)

AttributeError: 'numpy.ndarray' object has no attribute 'read'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants