Skip to content

Conversation

@kaushikb11
Copy link
Contributor

PR Description

Add comprehensive visualization module for displaying VLM Run results with images:

  • Support for bounding box visualization with customizable styles
    • Configurable colors, line thickness, and label display
    • Optional content and confidence score labels
    • Background highlighting for better text visibility
  • Flexible display options for single and batch results
    • Support for both single and multiple image-result pairs
    • Limit option for large result sets
    • Automatic handling of different input types (paths, PIL Images)
  • HTML table output with customizable styling
    • Responsive table layout with configurable CSS
    • JSON formatting with proper indentation
    • Base64 image encoding for notebook compatibility
    • Maximum height scrolling for large responses
  • Support for nested metadata and custom field selection
  • Render types as an option for users

Example usage:

show_results(
    response,
    image,
    render_type='bboxes',
    show_content=True,
    show_confidence=True
)

@kaushikb11 kaushikb11 merged commit 88bcca9 into main Mar 6, 2025
4 checks passed
@@ -1,5 +1,8 @@
cachetools
IPython
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't add IPython as a core dependency unless we need it.

return img


def render_image(image: ImageType, width: Optional[int] = None) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's move this into vlmrun.common.jupyter.format_image_html

}


def format_json_html(data: Dict[str, Any], indent: int = 2) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

Move to vlmrun.common.jupyter.format_json_html

return f'<pre style="margin: 0; white-space: pre-wrap;">{json_str}</pre>'


def show_results(
Copy link
Contributor

Choose a reason for hiding this comment

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

Move to vlmrun/common/jupyter/

raise ValueError("image_width must be a positive integer")


def xywh_to_xyxy(box: XYWHBox) -> BoundingBox:
Copy link
Contributor

Choose a reason for hiding this comment

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

Would prefer if we have a BoundingBox class and have classmethods for these to_xyxy, to_xywh etc.

return (x, y, x + w, y + h)


def extract_bbox(value: Union[Dict, List]) -> Optional[BoundingBox]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Use BoundingBox.from_dict

return None


def get_boxes_from_response(response: Union[Dict, Any]) -> List[Dict[str, BoundingBox]]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we want the attributes casted into BoundingBox instead?

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.

3 participants