🎉 30% OFF Pro Plan今すぐ申し込む
Medical AI Background

API アクセス

MedGemma & MedSigLIP API 使用ガイド

包括的な API アクセスを通じて Google の医療 AI モデルを開始しましょう。API キーを申請し、高度な医療 AI 機能をアプリケーションに統合します。

API アクセスを申請

MedGemma と MedSigLIP API を開始

MedGemma API

高度な医療テキストおよびマルチモーダル AI モデル

医療テキスト分析、画像理解、臨床意思決定支援のための MedGemma の強力な機能にアクセスします。

主要機能

  • 医療テキストの生成と分析
  • マルチモーダル医療画像とテキスト処理
  • 臨床質問応答
  • 医療レポート生成
  • ファインチューニング機能

利用可能なモデル

MedGemma 4B マルチモーダル

医療画像とテキストタスク用の軽量モデル

40億パラメータ

MedGemma 27B テキストのみ

医療テキストに特化した大規模言語モデル

270億パラメータ

MedGemma 27B マルチモーダル

複雑な医療タスク用の高度なマルチモーダルモデル

270億パラメータ

MedSigLIP API

分類と検索のための医療画像テキストエンコーダー

医療画像分類、ゼロショット推論、セマンティック検索のための MedSigLIP の効率的なデュアルタワーアーキテクチャを活用します。

主要機能

  • ゼロショット医療画像分類
  • セマンティック画像検索
  • 医療画像埋め込み
  • データ効率的分類
  • クロスモーダル類似性検索

モデル仕様

パラメータ:4億パラメータ
画像サイズ:448×448ピクセル
テキスト長:最大64トークン
アーキテクチャ:デュアルタワーエンコーダー(ビジョン + テキスト)

デプロイメントオプション

ニーズに最適なデプロイメント方法を選択

ローカルデプロイメント

Hugging Face transformers を使用してローカルでモデルを実行

Pros:

  • +完全制御
  • +API制限なし
  • +データプライバシー

Cons:

  • -GPUリソースが必要
  • -セットアップの複雑さ
Best for: 開発とテスト

Vertex AI デプロイメント

Google Cloud で REST API エンドポイントとしてデプロイ

Pros:

  • +スケーラブル
  • +管理されたインフラ
  • +本番対応

Cons:

  • -使用コスト
  • -クラウド依存
Best for: 本番アプリケーション

バッチ処理

Vertex AI バッチジョブで大規模データセットを処理

Pros:

  • +コスト効率
  • +大規模処理

Cons:

  • -リアルタイムでない
  • -バッチスケジューリング
Best for: 大量データ処理

Code Examples

Get started with implementation examples

MedGemma Implementation

Local Deployment

from transformers import pipeline

# Load MedGemma model
pipe = pipeline(
    "text-generation",
    model="google/medgemma-27b-text-it",
    torch_dtype="bfloat16",
    device="cuda"
)

# Generate medical text
response = pipe(
    "What are the symptoms of diabetes?",
    max_length=200,
    temperature=0.7
)

print(response[0]['generated_text'])

Vertex AI REST API

import requests
import json

# Vertex AI endpoint
endpoint_url = "https://your-endpoint.googleapis.com/v1/projects/your-project/locations/us-central1/endpoints/your-endpoint:predict"

# Request payload
payload = {
    "instances": [{
        "prompt": "What are the symptoms of diabetes?",
        "max_tokens": 200,
        "temperature": 0.7
    }]
}

# Make API request
headers = {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Content-Type": "application/json"
}

response = requests.post(endpoint_url, json=payload, headers=headers)
result = response.json()

print(result['predictions'][0]['generated_text'])

MedSigLIP Implementation

Local Deployment

from transformers import AutoModel, AutoProcessor
import torch
from PIL import Image

# Load MedSigLIP model
model = AutoModel.from_pretrained("google/medsiglip")
processor = AutoProcessor.from_pretrained("google/medsiglip")

# Load and process image
image = Image.open("medical_image.jpg")
text = "chest x-ray showing pneumonia"

# Process inputs
inputs = processor(
    text=[text],
    images=[image],
    return_tensors="pt",
    padding=True
)

# Get embeddings
with torch.no_grad():
    outputs = model(**inputs)
    image_embeds = outputs.image_embeds
    text_embeds = outputs.text_embeds

# Calculate similarity
similarity = torch.cosine_similarity(image_embeds, text_embeds)
print(f"Similarity score: {similarity.item():.4f}")

Zero-shot Classification

import torch
from transformers import AutoModel, AutoProcessor
from PIL import Image

# Load model and processor
model = AutoModel.from_pretrained("google/medsiglip")
processor = AutoProcessor.from_pretrained("google/medsiglip")

# Define classification labels
labels = [
    "normal chest x-ray",
    "pneumonia chest x-ray",
    "covid-19 chest x-ray",
    "lung cancer chest x-ray"
]

# Load image
image = Image.open("chest_xray.jpg")

# Process inputs
inputs = processor(
    text=labels,
    images=[image] * len(labels),
    return_tensors="pt",
    padding=True
)

# Get predictions
with torch.no_grad():
    outputs = model(**inputs)
    logits = outputs.logits_per_image
    probs = torch.softmax(logits, dim=-1)

# Get top prediction
top_idx = torch.argmax(probs, dim=-1)
confidence = probs[0, top_idx].item()

print(f"Prediction: {labels[top_idx]}")
print(f"Confidence: {confidence:.4f}")