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

Extend inference SDK with client for (almost all) core models #212

Merged
merged 6 commits into from
Dec 28, 2023

Conversation

PawelPeczek-Roboflow
Copy link
Collaborator

@PawelPeczek-Roboflow PawelPeczek-Roboflow commented Dec 28, 2023

Description

New client methods making it possible to call core models (apart from SAM)

New API:

from inference_sdk import InferenceHTTPClient

LOCALHOST_CLIENT = InferenceHTTPClient(
    api_url="http://127.0.0.1:9001",
    api_key=API_KEYS["MY_WORKSPACE_API_KEY"],
)

LOCALHOST_CLIENT.ocr_image("https://jeroen.github.io/images/testocr.png")
LOCALHOST_CLIENT.ocr_image(["https://jeroen.github.io/images/testocr.png"]*2)

LOCALHOST_CLIENT.detect_gazes(
    "https://t3.ftcdn.net/jpg/02/43/12/34/360_F_243123463_zTooub557xEWABDLk0jJklDyLSGl2jrr.jpg"
)
LOCALHOST_CLIENT.detect_gazes(
    ["https://t3.ftcdn.net/jpg/02/43/12/34/360_F_243123463_zTooub557xEWABDLk0jJklDyLSGl2jrr.jpg"] * 3
)

LOCALHOST_CLIENT.get_clip_image_embeddings(
    inference_input="https://t3.ftcdn.net/jpg/02/43/12/34/360_F_243123463_zTooub557xEWABDLk0jJklDyLSGl2jrr.jpg",
)
LOCALHOST_CLIENT.get_clip_image_embeddings(
    inference_input=["https://t3.ftcdn.net/jpg/02/43/12/34/360_F_243123463_zTooub557xEWABDLk0jJklDyLSGl2jrr.jpg"]*3,
)

LOCALHOST_CLIENT.get_clip_text_embeddings(
    text="Quick brawn fox",
)
LOCALHOST_CLIENT.get_clip_text_embeddings(
    text=["Quick brawn fox"]*5,
)

LOCALHOST_CLIENT.clip_compare(
    subject="Quick brawn fox",
    prompt=["Quick brown fox", "Quick brawn dog"],
    subject_type="text",
)

LOCALHOST_CLIENT.clip_compare(
    subject="https://t3.ftcdn.net/jpg/02/43/12/34/360_F_243123463_zTooub557xEWABDLk0jJklDyLSGl2jrr.jpg",
    prompt=["https://t3.ftcdn.net/jpg/02/43/12/34/360_F_243123463_zTooub557xEWABDLk0jJklDyLSGl2jrr.jpg"]*2,
    prompt_type="image",
)


LOCALHOST_CLIENT.prompt_cogvlm(
    visual_prompt="https://t3.ftcdn.net/jpg/02/43/12/34/360_F_243123463_zTooub557xEWABDLk0jJklDyLSGl2jrr.jpg",
    text_prompt="What is the topic of that picture",
)
LOCALHOST_CLIENT.prompt_cogvlm(
    visual_prompt="https://t3.ftcdn.net/jpg/02/43/12/34/360_F_243123463_zTooub557xEWABDLk0jJklDyLSGl2jrr.jpg",
    text_prompt="So - what is your final judgement about the content of the picture?",
    chat_history=[("I think the image shows a XXX", "You are wrong - the image shows YYY")]
)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How has this change been tested, please provide a testcase or example of how you tested the change?

  • tested locally
  • new tests in CI
  • CI still green

Any specific deployment considerations

For example, documentation changes, usability, usage/costs, secrets, etc.

Docs

  • Docs updated? What were the changes:

@PawelPeczek-Roboflow PawelPeczek-Roboflow marked this pull request as ready for review December 28, 2023 17:50
@PawelPeczek-Roboflow PawelPeczek-Roboflow added the documentation Improvements or additions to documentation label Dec 28, 2023
@PawelPeczek-Roboflow PawelPeczek-Roboflow merged commit af4e410 into main Dec 28, 2023
4 checks passed
@PawelPeczek-Roboflow PawelPeczek-Roboflow deleted the feature/extend_inference_sdk branch December 28, 2023 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants