見出し画像

ComfyUI×FaceSwapでショート動画

皆さん、こんにちは。

最近、画像生成AIが普及し、至る所で見かけるようになりました。買い物中にふと手に取った商品のパッケージに描かれた女性の画像に、どこか違和感や不自然さを感じたことはありませんか?すでに私たちの生活の中に溶け込んでいることに驚かされます。

ところで、皆さんはTikTokやInstagramのリール動画を投稿していますか?承認欲求を満たすため、小遣い稼ぎをするためなど、理由はさまざまだと思いますが、悩みもあるのではないでしょうか。

私が感じる最大の弊害、最も嫌だと思うことがあります。それは「顔出し」です。

「上手にダンスできるから皆に見てもらいたい!」
「歌声を聴いてもらいたい!」
「こんな特技があることをみんなに見せたい!」

でも、顔は出したくない。身バレするのが嫌だ。仕方なく顔にスタンプを貼っている…。

そんな悩みを解決する方法を紹介します!この方法を使えば、顔を出さずにSNSにショート動画を投稿することができます。

もしかすると、あなたのショート動画がバズるかもしれません。InstagramやTikTokには「収益化プログラム」もあるので、小遣い稼ぎにもなるかもしれません。

まずは簡単な手順を紹介します。

1. ComfyUIを起動
2. ワークフローを読み込み
3. 動画と静止画をアップロード
4. AIにて合成
5. SNSに投稿

注意点として、Google colab上で動くプログラムです。Google colabの有料プランで無ければ動作しませんので予めご了承ください。

1.ComfyUIを起動する。
Google colabを開いてメニューからファイル-ノートブックを新規作成で新しくノートブックを作成します。
ランタイム-ランタイムのタイプを変更でGPUを選択します。ランタイムのタイプはPython3でGPUはT4等を選びます。
下記のコードを入力欄にコピペし、再生ボタンで実行します。起動には5分程度掛かりますので待ちましょう。
1番最後のURLをクリックすると別のタブでComfyUIが表示されます。

!apt -y install -qq aria2
!pip install -q torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2+cu118 torchtext==0.15.2 torchdata==0.6.1 --extra-index-url https://download.pytorch.org/whl/cu118 -U
!pip install onnxruntime-gpu

%cd /content
!git clone https://github.com/comfyanonymous/ComfyUI

%cd /content/ComfyUI
!pip install -r requirements.txt

# ComfyUI Managerのインストール
%cd /content/ComfyUI/custom_nodes
!git clone https://github.com/ltdrdata/ComfyUI-Manager.git
!git clone https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git


# ---------------- comfyui-reactor-nodeの設定開始 ---------------------
%cd /content/ComfyUI/custom_nodes

!git clone https://github.com/Gourieff/comfyui-reactor-node.git

%cd comfyui-reactor-node
!pip install -r requirements.txt
!python install.py

%cd /content/ComfyUI/custom_nodes
# ---------------- comfyui-reactor-nodeの設定終了 ---------------------

!wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
!dpkg -i cloudflared-linux-amd64.deb

import subprocess
import threading
import time
import socket

def iframe_thread(port):
    while True:
        time.sleep(0.5)
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        result = sock.connect_ex(('127.0.0.1', port))
        if result == 0:
            break
        sock.close()

    print("\nComfyUI finished loading, trying to launch cloudflared (if it gets stuck here cloudflared is having issues)\n")
    p = subprocess.Popen(["cloudflared", "tunnel", "--url", f"http://127.0.0.1:{port}"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    for line in p.stderr:
        l = line.decode()
        if "trycloudflare.com " in l:
            print("This is the URL to access ComfyUI:", l[l.find("http"):], end='')

%cd /content/ComfyUI

# スレッドの開始
threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()

# ComfyUIの実行
!python main.py --dont-print-server


ここから先は

629字 / 2画像 / 1ファイル

¥ 500

期間限定 PayPay支払いすると抽選でお得に!

この記事が参加している募集

#AIとやってみた

27,805件

サポート頂けると喜びます!ぜひお願いします!