github.com
今回使用したのは「controlnet-aux==0.0.7」です。
mediapipeも一緒にインストールする必要があります。
pip install controlnet-aux mediapipe
Pythonスクリプト
from diffusers.utils import load_image from controlnet_aux.processor import Processor image = load_image("https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/examples/sketch/human.png") image.save("human.png") # "depth_zoe", "dwpose" processor_id_list = [ "canny", "depth_leres", "depth_leres++", "depth_midas", "lineart_anime", "lineart_coarse", "lineart_realistic", "mediapipe_face", "mlsd", "normal_bae", "openpose", "openpose_face", "openpose_faceonly", "openpose_full", "openpose_hand", "scribble_hed", "scribble_hedsafe", "scribble_pidinet", "scribble_pidsafe", "shuffle", "softedge_hed", "softedge_hedsafe", "softedge_pidinet", "softedge_pidsafe" ] print(len(processor_id_list)) for processor_id in processor_id_list: processor = Processor(processor_id) processed_image = processor(image, to_pil=True) processed_image.save(f"{processor_id}.png")
元画像
結果
上記スクリプトを実行すると以下のような画像が作成されます。「depth_zoe」はうまくできませんでした。
github.com
以下のようにするとうまくいきます。
pip uninstall timm pip install timm==0.6.7
また、「depth_zoe」はなぜかtorch==2.1.xでも動作しません。
補足
「safe」については良くわかりません。スクリプトを覗くと以下を実行しているようです。
def safe_step(x, step=2): y = x.astype(np.float32) * float(step + 1) y = y.astype(np.int32).astype(np.float32) / float(step) return y
結果の画像を見比べても違いがよくわかりません。