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

[Devx:119] Models Interface #143

Merged
merged 4 commits into from
Aug 18, 2023
Merged

Conversation

sainivedh
Copy link
Contributor

@sainivedh sainivedh commented Aug 17, 2023

What

  • Added functionality to interface with Models(predict, list, versions)

How

Model Predict

from clarifai.client.model import Model

# Model Predict
model = Model(user_id="user_id", app_id="app_id", model_id="model_id")
model_prediction = model.predict_by_url(url="url", input_type="image") # Supports image, text, audio, video

# Customizing Model Inference Output
model = Model(user_id="user_id", app_id="app_id", model_id="model_id",
                  output_config={"min_value": 0.98}) # Return predictions having prediction confidence > 0.98
model_prediction = model.predict_by_filepath(filepath="local_filepath", input_type="text") # Supports image, text, audio, video

model = Model(user_id="user_id", app_id="app_id", model_id="model_id",
                    output_config={"sample_ms": 2000}) # Return predictions for specified interval
model_prediction = model.predict_by_url(url=BEER_VIDEO_URL, input_type="video")

Models Listing

# List all model versions
all_model_versions = model.list_versions()

# Go to specific model version
model_v1 = client.app("app_id").model("model_id", model_version_id="model_version_id")

# List all models in an app
all_models = app.list_models()

# List all models in community filtered by model_type, description
all_llm_community_models = App().list_models(filter_by={"query": "LLM",
                                                        "model_type_id": "text-to-text"}, only_in_app=False)

Tests

Unit tests added for Model predict with different scenarios

  • Predict by filepath, url, bytes
  • Predict by various output configs (max_concepts, min_value, selected_concepts)

Note

Skipping Model unit tests in build as secrets needed for PAT are not yet setup for this repo

@sainivedh sainivedh marked this pull request as ready for review August 17, 2023 16:41
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@stmugisha stmugisha left a comment

Choose a reason for hiding this comment

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

Looking good.
just a few comments

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
clarifai/client/model.py Show resolved Hide resolved
clarifai/client/model.py Outdated Show resolved Hide resolved
Copy link
Contributor

@sanjaychelliah sanjaychelliah left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@stmugisha stmugisha left a comment

Choose a reason for hiding this comment

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

LGTM

@sainivedh sainivedh merged commit 6df2eb1 into candidate-master Aug 18, 2023
4 checks passed
@sainivedh sainivedh deleted the DEVX-119-Models-Interface branch August 18, 2023 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants