hzhang57 / multimodal-maestro

Effective prompting for Large Multimodal Models like GPT-4 Vision or LLaVA. πŸ”₯

Home Page:https://roboflow.github.io/multimodal-maestro

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

multimodal-maestro


version license python-version Gradio Colab

πŸ‘‹ hello

Multimodal-Maestro gives you more control over large multimodal models to get the outputs you want. With more effective prompting tactics, you can get multimodal models to do tasks you didn't know (or think!) were possible. Curious how it works? Try our HF space!

🚧 The project is still under construction and the API is prone to change.

πŸ’» install

Pip install the supervision package in a 3.11>=Python>=3.8 environment.

pip install multimodal-maestro

πŸš€ examples

GPT-4 Vision

Find dog.

>>> The dog is prominently featured in the center of the image with the label [9].
πŸ‘‰ read more
  • load image

    import cv2
    
    image = cv2.imread("...")
  • create and refine marks

    import multimodalmaestro as mm
    
    generator = mm.SegmentAnythingMarkGenerator(device='cuda')
    marks = generator.generate(image=image)
    marks = mm.refine_marks(marks=marks)
  • visualize marks

    mark_visualizer = mm.MarkVisualizer()
    marked_image = mark_visualizer.visualize(image=image, marks=marks)

    image-vs-marked-image

  • prompt

    prompt = "Find dog."
    
    response = mm.prompt_image(api_key=api_key, image=marked_image, prompt=prompt)
    >>> "The dog is prominently featured in the center of the image with the label [9]."
    
  • extract related marks

    masks = mm.extract_relevant_masks(text=response, detections=refined_marks)
    >>> {'6': array([
    ...     [False, False, False, ..., False, False, False],
    ...     [False, False, False, ..., False, False, False],
    ...     [False, False, False, ..., False, False, False],
    ...     ...,
    ...     [ True,  True,  True, ..., False, False, False],
    ...     [ True,  True,  True, ..., False, False, False],
    ...     [ True,  True,  True, ..., False, False, False]])
    ... }
    

multimodal-maestro

🚧 roadmap

  • Documentation page.
  • Segment Anything guided marks generation.
  • Non-Max Suppression marks refinement.
  • LLaVA demo.

πŸ’œ acknowledgement

🦸 contribution

We would love your help in making this repository even better! If you noticed any bug, or if you have any suggestions for improvement, feel free to open an issue or submit a pull request.

About

Effective prompting for Large Multimodal Models like GPT-4 Vision or LLaVA. πŸ”₯

https://roboflow.github.io/multimodal-maestro

License:MIT License


Languages

Language:Python 100.0%