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

Add SmolVLM2 #1106

Merged
merged 29 commits into from
Apr 3, 2025
Merged

Add SmolVLM2 #1106

merged 29 commits into from
Apr 3, 2025

Conversation

capjamesg
Copy link
Contributor

Description

This PR adds SmolVLM2 to Inference.

Type of change

  • New model

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

You can test this change with the following code:

from PIL import Image
from inference.models.smolvlm.smolvlm import SmolVLM

pg = SmolVLM(api_key="YOUR_ROBOFLOW_KEY")

image = Image.open("image.jpeg")

prompt = "your prompt"

result = pg.predict(image, prompt)

print(result)

You should see a result like:

['User:\n\n\n\n\nCan you describe this image?\nAssistant: The image depicts a beagle dog sitting on a cobblestone path in what appears to be a courtyard or an alleyway. The dog is positioned in the foreground, facing the camera, with its front paws resting on the ground. The dog has a black muzzle, a white chest, and brown and black fur on']

Any specific deployment considerations

N/A

Docs

A docs page has been added for this model.

@@ -172,6 +176,15 @@ def get_model_type(
device_id=GLOBAL_DEVICE_ID,
).get("ort")
project_task_type = api_data.get("type", "object-detection")
elif model_id in FOUNDATION_MODELS_TO_DOWNLOAD_AS_CORE:
api_data = get_roboflow_model_data(
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is that needed here but wasnt needed for other core models?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am a little bit shaky letting that go to main

Copy link
Collaborator

Choose a reason for hiding this comment

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

if required - should be set instead of list for faster lookup as models pool grows

Copy link
Collaborator

@PawelPeczek-Roboflow PawelPeczek-Roboflow left a comment

Choose a reason for hiding this comment

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

looks good, but please explain the changes in get_model_type

@PawelPeczek-Roboflow
Copy link
Collaborator

why GENERIC_MODELS would not be used instead of creating FOUNDATION_MODELS_TO_DOWNLOAD_AS_CORE

@PawelPeczek-Roboflow
Copy link
Collaborator

@capjamesg - chane will not be pushed to release if comments are not addressed.

@@ -163,7 +167,7 @@ def get_model_type(
model_type=model_type,
)
return project_task_type, model_type

model_type = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably not needed modification

workflow_definition=SMOLVLM2_WORKFLOW_DEFINITION,
workflow_name_in_app="smolvlm2"
)
# @pytest.mark.skipif(
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove commented out code

Copy link
Collaborator

@PawelPeczek-Roboflow PawelPeczek-Roboflow left a comment

Choose a reason for hiding this comment

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

looks good, please revert not needed change from inference/core/registries/roboflow.py

# some older projects do not have type field - hence defaulting
model_type = api_data.get("modelType")
if not model_type:
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be adjusted

@capjamesg capjamesg merged commit d97d4ae into main Apr 3, 2025
31 checks passed
@capjamesg capjamesg deleted the add-smolvlm branch April 3, 2025 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants