Sign inSign up

bhimrazy/phi-4-multimodal

By bhimrazy

•Updated over 1 year ago

LitServe image of Phi4 Multimodal Phi-4 Multimodal: Unleash Speech, Vision, and Text in One Click

Image
Machine learning & AI
Web servers
0

10K+

bhimrazy/phi-4-multimodal repository overview

⁠Phi-4 Multimodal: Unleash Speech, Vision, and Text in One Click

Artificial Intelligence just got a major upgrade with Phi-4 Multimodal, a compact yet powerful model from Microsoft that blends speech, vision, and text processing into one seamless package. With only 5.6 billion parameters, it punches above its weight, rivaling larger models in tasks like math, coding, and multimodal reasoning. Whether you’re a developer, researcher, or innovator, this model opens the door to smarter, more natural applications—think virtual assistants that see, hear, and respond with context.

⁠Run the phi-4-multimodal container from Docker Hub

docker run -p 8000:8000 bhimrazy/phi-4-multimodal:latest

⁠API Usage (Python)

⁠Using requests:
import requests

# Replace this url with the link to your deployed API
DEPLOYED_API_URL = "http://127.0.0.1:8000"

url = f"{DEPLOYED_API_URL}/v1/chat/completions"
response = requests.post(url, json={
  "model": "microsoft/Phi-4-multimodal-instruct",
  "messages": [{
    "role": "user",
    "content": [
      {"type": "image_url", "image_url": {"url": "https://www.ilankelman.org/stopsigns/australia.jpg"}},
      {"type": "text", "text": "What’s in this image?"}
    ]
  }],
  "temperature": 0.7,
  "max_tokens": 512
})

print(response.json()["choices"][0]["message"]["content"])
Output: "The image shows a street scene with a prominent red STOP sign in the foreground. The background features a traditional Chinese architectural structure with red and green colors, banners, and statues. There are trees, buildings, and a dark-colored car parked on the street."
⁠Using standard OpenAI Python SDK:
from openai import OpenAI

client = OpenAI(
    base_url="http://127.0.0.1:8000/v1",  # Update the endpoint
    api_key=None,  # Update the API key if available
)

response = client.chat.completions.create(
    model="microsoft/Phi-4-multimodal-instruct",
    messages=[{
      "role": "user",
      "content": [
        {"type": "image_url", "image_url": {"url": "https://www.ilankelman.org/stopsigns/australia.jpg"}},
        {"type": "text", "text": "What’s in this image?"}
      ]
    }
  ],
   max_tokens=512
)

print(response)

This API returns a JSON response with the generated text.

{
  "id": "chatcmpl-4f75f8",
  "object": "chat.completion",
  "created": 1740892704,
  "model": "microsoft/Phi-4-multimodal-instruct",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The image shows a street scene with a prominent red STOP sign in the foreground. The background features a traditional Chinese architectural structure with red and green colors, banners, and statues. There are trees, buildings, and a dark-colored car parked on the street.",
        "name": null,
        "tool_calls": null,
        "tool_call_id": null
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "total_tokens": 0,
    "completion_tokens": 0
  }
}

Tag summary

Content type

Image

Digest

sha256:ca469507e…

Size

7.7 GB

Last updated

over 1 year ago

docker pull bhimrazy/phi-4-multimodal