🚀 顔パーシング
このモデルは、[nvidia/mit - b5](https://huggingface.co/nvidia/mit - b5) を [CelebAMask - HQ](https://github.com/switchablenorms/CelebAMask - HQ) でファインチューニングした、顔パーシング用のセマンティックセグメンテーション モデルです。追加のオプションについては、Transformersの Segformerドキュメント を参照してください。

Xenova が提供したウェブ推論用のONNXモデルです。
🚀 クイックスタート
ラベル情報
完全なラベルリストは、[config.json](https://huggingface.co/jonathandinu/face - parsing/blob/65972ac96180b397f86fda0980bbe68e6ee01b8f/config.json#L30) から抽出できます。
id |
ラベル |
備考 |
0 |
background |
|
1 |
skin |
|
2 |
nose |
|
3 |
eye_g |
メガネ |
4 |
l_eye |
左眼 |
5 |
r_eye |
右眼 |
6 |
l_brow |
左眉 |
7 |
r_brow |
右眉 |
8 |
l_ear |
左耳 |
9 |
r_ear |
右耳 |
10 |
mouth |
唇の間の領域 |
11 |
u_lip |
上唇 |
12 |
l_lip |
下唇 |
13 |
hair |
|
14 |
hat |
|
15 |
ear_r |
イヤリング |
16 |
neck_l |
ネックレス |
17 |
neck |
|
18 |
cloth |
衣服 |
💻 使用例
Pythonでの使用
import torch
from torch import nn
from transformers import SegformerImageProcessor, SegformerForSemanticSegmentation
from PIL import Image
import matplotlib.pyplot as plt
import requests
device = (
"cuda"
if torch.cuda.is_available()
else "mps"
if torch.backends.mps.is_available()
else "cpu"
)
image_processor = SegformerImageProcessor.from_pretrained("jonathandinu/face-parsing")
model = SegformerForSemanticSegmentation.from_pretrained("jonathandinu/face-parsing")
model.to(device)
url = "https://images.unsplash.com/photo-1539571696357-5a69c17a67c6"
image = Image.open(requests.get(url, stream=True).raw)
inputs = image_processor(images=image, return_tensors="pt").to(device)
outputs = model(**inputs)
logits = outputs.logits
upsampled_logits = nn.functional.interpolate(logits,
size=image.size[::-1],
mode='bilinear',
align_corners=False)
labels = upsampled_logits.argmax(dim=1)[0]
labels_viz = labels.cpu().numpy()
plt.imshow(labels_viz)
plt.show()
ブラウザでの使用 (Transformers.js)
import {
pipeline,
env,
} from "https://cdn.jsdelivr.net/npm/@xenova/transformers@2.14.0";
env.allowLocalModels = false;
model = await pipeline("image-segmentation", "jonathandinu/face-parsing");
const output = await model(url);
for (const m of output) {
print(`Found ${m.label}`);
m.mask.save(`${m.label}.png`);
}
p5.jsでの使用
p5.js はアニメーションループ抽象化を使用しているため、モデルの読み込みと予測を行う際に注意が必要です。
async function preload() {
const { pipeline, env } = await import(
"https://cdn.jsdelivr.net/npm/@xenova/transformers@2.14.0"
);
env.allowLocalModels = false;
model = await pipeline("image-segmentation", "jonathandinu/face-parsing");
print("face-parsing model loaded");
}
完全なp5.jsの例
📚 ドキュメント
モデルの説明
🔧 技術詳細
バイアスと制限
コンピュータビジョンモデルの能力は印象的ですが、社会的バイアスを強化または悪化させる可能性もあります。ファインチューニングに使用される [CelebAMask - HQ](https://github.com/switchablenorms/CelebAMask - HQ) データセットは大規模ですが、必ずしも完全に多様または代表的ではありません。また、これらは有名人の画像です。