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

Adding additional interface for Object Detection #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MichaelLantz
Copy link

Hi @MinuraPunchihewa!

First off I want to thank you for your contributions. I've been having a blast playing with the functionality.

I added this for something I'm testing but I'm hoping you / others can benefit.

Change: Adding additional interface for Object Detection in addition to error catching API calls to return JSON when no image / object labels get returned

Adding additional interface for Object Detection in addition to error catching API calls to return JSON when no image / object labels get returned
@MichaelLantz
Copy link
Author

Using https://github.com/MichaelLantz/mindsdb/tree/ml_integration/hf_inference_api_playground these are some tests I ran successfully:

CREATE MODEL mindsdb.hf_object_detection PREDICT detection USING task = 'object-detection', engine = 'hf_api_engine', api_key = 'hf_...', column = 'image'

followed by:

SELECT image, detection FROM mindsdb.hf_object_detection WHERE image = 'https://raw.githubusercontent.com/MinuraPunchihewa/hugging-py-face/main/tests/resources/dogs.jpeg';

image

@MinuraPunchihewa
Copy link
Owner

Hey @MichaelLantz,
I am so incredibly honored to say that you are the first contributor to this project! Thank you so much for taking the time!
I have comment on the awesome contribution that you have made. I will submit a review now.
By the way, I'd really appreciate it if you could leave ⭐ on the repo if you think this is cool.

return self._query(inputs, model=model, task="object-detection")

def object_detection_in_df(self, df: DataFrame, column: Text, model: Optional[Text] = None) -> DataFrame:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really awesome! I was just thinking that since this is object detection, we might need to include the coordinates as well? What do you think? We can maybe include these in separate columns in the resulting DataFrame?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All thanks goes to you good sir! I'm just a fan who hopes I'm not making things worse. Coordinates will definitely be helpful especially if we want to augment images to pinpoint objects. I was messing around in my development area but need a little more time to try that without adding too much bloat to the codebase.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are making it much better! I was wondering how to tackle the object detection task and your help is much appreciated. Please take your time and reach out to me anytime if you want to talk it out.


def object_detection_in_df(self, df: DataFrame, column: Text, model: Optional[Text] = None) -> DataFrame:
"""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something else that I was thinking about is, given the situation that multiple objects are detected in a single image, we will only be returning the first one. Maybe we can include all of the objects detected for a particular image in separate rows? What do you feel about this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I noticed this behavior. I think having all objects might be a good option and allows for extensibility. In my case I was happy with a single result for the first iteration. Having any accurate result was a huge win to start as far as I was concerned.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Let's see what we can do to support this.

@MinuraPunchihewa
Copy link
Owner

@MichaelLantz A couple of things,

  • I made a few changes recently, so please pull from the main branch, if you don't mind.
  • I have created an issue for the task that you are working on and I can assign that to you if you like. If you want me to assign it, could you please comment on the issue,
    Adding Support for Object Detection on DataFrames #11

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

Successfully merging this pull request may close these issues.

2 participants