Skip to Content
ドキュメントAIAI 画像と音声

AI 画像と音声

AI テクノロジーはテキストを処理するだけではなく、高品質の画像を生成したり、音声を処理したりすることができます。この記事では、主流の AI 画像生成および音声認識ツールを Ubuntu 26.04 にインストールして使用する方法について説明します。

安定拡散 WebUI (AUTOMATIC1111)

AUTOMATIC1111 の Stable Diffusion WebUI は、最も人気のある AI 画像生成ツールであり、テキストから画像 (txt2img)、画像から画像 (img2img)、修復などをサポートする機能豊富な Web インターフェイスを提供します。

システム要件

  • 8GB 以上の VRAM を搭載した NVIDIA GPU を推奨
  • Python 3.10+
  • 少なくとも 15 GB のディスク容量 (基本モデルはそれぞれ 4 ~ 7 GB)

依存関係のインストール

# Install system dependencies sudo apt update sudo apt install -y git python3 python3-venv python3-pip \ libgl1 libglib2.0-0 libsm6 libxext6 libxrender1 \ wget curl # Ensure NVIDIA drivers and CUDA are installed (see GPU Setup section) nvidia-smi

Stable Diffusion WebUI をインストールする

# Clone the repository cd ~ git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git cd stable-diffusion-webui # First launch (automatically installs Python dependencies and downloads base models) # This may take 10-30 minutes depending on network speed ./webui.sh
# Custom launch parameters ./webui.sh --listen --port 7860 --enable-insecure-extension-access # Common launch parameters: # --listen Allow remote access (default is local only) # --port 7860 Specify port # --xformers Enable xformers acceleration (recommended) # --medvram Medium VRAM optimization (recommended for 8GB GPUs) # --lowvram Low VRAM optimization (for 4-6GB GPUs) # --no-half Disable half precision (needed for some AMD GPUs)

モデルをダウンロードする

Stable Diffusion のコアはチェックポイント モデル ファイルです。このファイルは手動でダウンロードして、指定されたディレクトリに配置する必要があります。

# Model storage directory mkdir -p ~/stable-diffusion-webui/models/Stable-diffusion # Download Stable Diffusion XL base model wget -O ~/stable-diffusion-webui/models/Stable-diffusion/sd_xl_base_1.0.safetensors \ "https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors" # Download SDXL Refiner (optional, for image refinement) wget -O ~/stable-diffusion-webui/models/Stable-diffusion/sd_xl_refiner_1.0.safetensors \ "https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/resolve/main/sd_xl_refiner_1.0.safetensors"
# Download VAE model (improves image colors) mkdir -p ~/stable-diffusion-webui/models/VAE wget -O ~/stable-diffusion-webui/models/VAE/sdxl_vae.safetensors \ "https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors"

人気のコミュニティモデルをダウンロード

コミュニティは、Civitai と Hugging Face に関する多くの微調整されたモデルを提供しています。

# Place models in the corresponding directories # Checkpoint models -> models/Stable-diffusion/ # LoRA models -> models/Lora/ # VAE models -> models/VAE/ # Embeddings -> embeddings/ mkdir -p ~/stable-diffusion-webui/models/Lora mkdir -p ~/stable-diffusion-webui/embeddings # Example: download a model from Hugging Face # wget -O ~/stable-diffusion-webui/models/Stable-diffusion/model_name.safetensors "download-link"

WebUIの使用

起動後、ブラウザで http://localhost:7860 にアクセスします。

  1. txt2img — 画像を生成するためのプロンプトを入力します
  2. img2img — 参照画像をアップロードし、プロンプトに基づいて変更します。
  3. 修復 — ローカル再描画する画像の領域を選択します
  4. 拡張機能 — プラグインをインストールして機能を拡張します

プロンプトの例:

Positive prompt: a beautiful mountain landscape, sunset, golden hour, photorealistic, 8k, masterpiece, best quality Negative prompt: blurry, low quality, distorted, watermark, text

起動スクリプトを作成する

cat > ~/stable-diffusion-webui/start.sh << 'EOF' #!/bin/bash cd ~/stable-diffusion-webui ./webui.sh --listen --xformers --enable-insecure-extension-access EOF chmod +x ~/stable-diffusion-webui/start.sh
Tip

GPU に 8GB VRAM が搭載されている場合は、--medvram --xformers で起動することをお勧めします。 SDXL モデルの場合、最高のエクスペリエンスを実現するには、少なくとも 10GB VRAM が推奨されます。 SD 1.5 シリーズ モデルは、わずか 4GB VRAM でスムーズに動作します。


快適なUI

ComfyUI は、ビジュアル ノード接続を通じて画像生成パイプラインを構築するノードベースのワークフロー AI 画像生成ツールで、非常に高い柔軟性を提供します。

ComfyUI をインストールする

# Install system dependencies sudo apt install -y git python3 python3-venv python3-pip # Clone ComfyUI cd ~ git clone https://github.com/comfyanonymous/ComfyUI.git cd ComfyUI # Create a Python virtual environment python3 -m venv venv source venv/bin/activate # Install PyTorch (CUDA version) pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126 # Install ComfyUI dependencies pip install -r requirements.txt

ComfyUI を起動する

cd ~/ComfyUI source venv/bin/activate # Launch (default port 8188) python main.py # Allow remote access python main.py --listen 0.0.0.0 --port 8188 # Low VRAM mode python main.py --lowvram

モデルのインストール

ComfyUI のモデル ディレクトリ構造:

# Model directories ls ~/ComfyUI/models/ # checkpoints/ -- Checkpoint models # clip/ -- CLIP models # loras/ -- LoRA models # vae/ -- VAE models # controlnet/ -- ControlNet models # upscale_models/ -- Upscaling models # You can reuse AUTOMATIC1111 models via symlinks ln -s ~/stable-diffusion-webui/models/Stable-diffusion/* ~/ComfyUI/models/checkpoints/ ln -s ~/stable-diffusion-webui/models/Lora/* ~/ComfyUI/models/loras/ ln -s ~/stable-diffusion-webui/models/VAE/* ~/ComfyUI/models/vae/

ノードのワークフロー

ComfyUI はノードと接続を使用して画像生成パイプラインを構築します。

  1. ブラウザを開いて http://localhost:8188 にアクセスします
  2. デフォルトのワークフローには、基本的な txt2img ノードが含まれています
  3. キャンバスを右クリックして新しいノードを追加します
  4. 「プロンプトをキュー」をクリックして生成を開始します

ComfyUI Manager をインストールします (推奨):

# ComfyUI Manager makes it easy to manage custom nodes cd ~/ComfyUI/custom_nodes git clone https://github.com/ltdrdata/ComfyUI-Manager.git # After restarting ComfyUI, a Manager button will appear in the interface

人気のあるカスタム ノード

cd ~/ComfyUI/custom_nodes # Advanced ControlNet nodes git clone https://github.com/Fannovel16/comfyui_controlnet_aux.git # IP-Adapter nodes (style transfer) git clone https://github.com/cubiq/ComfyUI_IPAdapter_plus.git # Image upscaling nodes git clone https://github.com/ssitu/ComfyUI_UltimateSDUpscale.git # Install dependencies for each node cd ~/ComfyUI source venv/bin/activate for dir in custom_nodes/*/; do if [ -f "$dir/requirements.txt" ]; then pip install -r "$dir/requirements.txt" fi done
Note

ComfyUI は AUTOMATIC1111 WebUI よりも学習曲線が急ですが、柔軟性と再現性が優れています。デフォルトのワークフローから始めて、徐々に複雑なノードを追加していきます。コミュニティ共有ワークフローは、https://comfyworkflows.com  または https://openart.ai/workflows . からダウンロードできます。


OpenAI ウィスパー

OpenAI Whisper は、非常に高い精度で複数言語の音声テキスト変換をサポートする強力な音声認識モデルです。

ウィスパーをインストールする

# Install system dependencies sudo apt install -y python3 python3-pip python3-venv ffmpeg # Create a virtual environment (recommended) python3 -m venv ~/whisper-env source ~/whisper-env/bin/activate # Install Whisper pip install openai-whisper # Or install with GPU acceleration (requires CUDA) pip install openai-whisper torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126

音声からテキストへ

# Activate virtual environment source ~/whisper-env/bin/activate # Basic usage: transcribe an audio file whisper audio.mp3 --language en --model medium # Specify output format whisper audio.mp3 --language en --model medium --output_format txt whisper audio.mp3 --language en --model medium --output_format srt # Subtitle format whisper audio.mp3 --language en --model medium --output_format vtt # WebVTT format whisper audio.mp3 --language en --model medium --output_format json # Auto-detect language whisper audio.mp3 --model medium # Specify output directory whisper audio.mp3 --language en --model medium --output_dir ~/transcripts/

ウィスパーモデルのサイズ

モデルパラメータVRAMが必要です相対速度正確さ
tiny39M~1GB最速公平
base74M~1GB非常に速い良い
small244M~2GB速いより良い
medium769M~5GB中くらいとても良い
large-v31.5B~10GBもっとゆっくり最高
turbo809M~6GB速いとても良い
# Use different model sizes whisper audio.mp3 --model tiny # Fast but lower accuracy whisper audio.mp3 --model small # Balance of speed and accuracy whisper audio.mp3 --model large-v3 # Highest accuracy whisper audio.mp3 --model turbo # Balance of speed and large model accuracy

Python の使用法

import whisper # Load model model = whisper.load_model("medium") # Transcribe audio result = model.transcribe("audio.mp3", language="en") # Output text print(result["text"]) # Output segments with timestamps for segment in result["segments"]: print(f"[{segment['start']:.1f}s - {segment['end']:.1f}s] {segment['text']}")

高速ウィスパーの使用 (推奨)

Faster-Whisper は CTranslate2 エンジンを使用し、元の Whisper よりも 4 倍高速で、VRAM 使用量が低くなります。

# Install faster-whisper pip install faster-whisper
from faster_whisper import WhisperModel # Load model (auto-downloads) model = WhisperModel("medium", device="cuda", compute_type="float16") # Transcribe segments, info = model.transcribe("audio.mp3", language="en") print(f"Detected language: {info.language}, confidence: {info.language_probability:.2f}") for segment in segments: print(f"[{segment.start:.1f}s -> {segment.end:.1f}s] {segment.text}")
# faster-whisper command line usage pip install faster-whisper-cli faster-whisper audio.mp3 --language en --model medium --output_format srt

オーディオのバッチ処理

# Create a batch transcription script cat > ~/transcribe.sh << 'SCRIPT' #!/bin/bash # Batch transcribe all audio files in a directory INPUT_DIR="${1:-.}" OUTPUT_DIR="${2:-./transcripts}" MODEL="${3:-medium}" source ~/whisper-env/bin/activate mkdir -p "$OUTPUT_DIR" for file in "$INPUT_DIR"/*.{mp3,wav,m4a,flac,ogg}; do [ -f "$file" ] || continue echo "Transcribing: $file" whisper "$file" --language en --model "$MODEL" \ --output_format srt --output_dir "$OUTPUT_DIR" done echo "Transcription complete! Results saved to $OUTPUT_DIR" SCRIPT chmod +x ~/transcribe.sh # Use the script # ~/transcribe.sh ~/audio_files ~/output medium
Tip

一般的な文字起こしの場合、medium モデルが精度と速度の最適なバランスを提供します。精度を最大にするには、large-v3 を使用してください。リアルタイムの転写や大量のファイルの処理には、faster-whisper を使用してください。同じ精度レベルで約 4 倍の速度向上が得られます。


ツールの比較

道具タイプGPUが必要最適な用途
AUTOMATIC1111 WebUI画像生成4GB以上初心者に優しいフル機能
快適なUI画像生成4GB以上高度なワークフロー、再現性
ささやき音声からテキストへの変換オプション音声転写、字幕
より早いささやき声音声からテキストへの変換推奨大音量のオーディオ処理