Instructions to use kwanY/styleid with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kwanY/styleid with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-image-classification", model="kwanY/styleid") pipe( "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png", candidate_labels=["animals", "humans", "landscape"], )# Load model directly from transformers import AutoProcessor, AutoModelForZeroShotImageClassification processor = AutoProcessor.from_pretrained("kwanY/styleid") model = AutoModelForZeroShotImageClassification.from_pretrained("kwanY/styleid") - Notebooks
- Google Colab
- Kaggle
Improve model card metadata and content
#1
by nielsr HF Staff - opened
README.md
CHANGED
|
@@ -1,17 +1,19 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
| 3 |
---
|
| 4 |
|
| 5 |
-
|
| 6 |
# StyleID — Stylization-Agnostic Identity Encoder
|
|
|
|
| 7 |
[](https://arxiv.org/abs/2604.21689)
|
| 8 |
[](https://kwanyun.github.io/StyleID_page/)
|
|
|
|
| 9 |
|
|
|
|
| 10 |
|
| 11 |
-
StyleID is a CLIP-based image encoder trained to produce identity embeddings that are robust to stylization.
|
| 12 |
It can be used for identity similarity, retrieval, evaluation, and conditioning in generative models.
|
| 13 |
|
| 14 |
-
|
| 15 |
<img src="https://cdn-uploads.huggingface.co/production/uploads/639d445524af4747d8d2af52/1pTEZ88YvwnbDPlV_UqpM.jpeg" width="700">
|
| 16 |
|
| 17 |
---
|
|
@@ -19,28 +21,57 @@ It can be used for identity similarity, retrieval, evaluation, and conditioning
|
|
| 19 |
## Installation
|
| 20 |
|
| 21 |
```bash
|
| 22 |
-
pip install transformers pillow
|
| 23 |
```
|
| 24 |
|
| 25 |
## Usage
|
| 26 |
-
#### Do not use for multiple faces or faces too small to recognize.
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
| 29 |
import torch
|
| 30 |
from transformers import CLIPModel, CLIPProcessor
|
| 31 |
from PIL import Image
|
| 32 |
|
| 33 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 34 |
|
|
|
|
| 35 |
model = CLIPModel.from_pretrained("kwanY/styleid").to(device)
|
| 36 |
processor = CLIPProcessor.from_pretrained("kwanY/styleid")
|
| 37 |
|
|
|
|
|
|
|
| 38 |
img = Image.open(img_path).convert("RGB")
|
| 39 |
inputs = processor(images=img, return_tensors="pt").to(device)
|
| 40 |
|
|
|
|
| 41 |
with torch.no_grad():
|
| 42 |
emb = model.get_image_features(**inputs)
|
| 43 |
emb = emb / emb.norm(dim=-1, keepdim=True) # optional but recommended
|
| 44 |
```
|
| 45 |
|
| 46 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
pipeline_tag: image-feature-extraction
|
| 4 |
+
license: other
|
| 5 |
---
|
| 6 |
|
|
|
|
| 7 |
# StyleID — Stylization-Agnostic Identity Encoder
|
| 8 |
+
|
| 9 |
[](https://arxiv.org/abs/2604.21689)
|
| 10 |
[](https://kwanyun.github.io/StyleID_page/)
|
| 11 |
+
[](https://github.com/kwanyun/StyleID)
|
| 12 |
|
| 13 |
+
StyleID is a CLIP-based image encoder trained to produce identity embeddings that are robust to stylization (e.g., cartoons, sketches, and paintings). It is designed to maintain identity recognition even when artistic styles cause significant domain shifts in texture, color, or geometry.
|
| 14 |
|
|
|
|
| 15 |
It can be used for identity similarity, retrieval, evaluation, and conditioning in generative models.
|
| 16 |
|
|
|
|
| 17 |
<img src="https://cdn-uploads.huggingface.co/production/uploads/639d445524af4747d8d2af52/1pTEZ88YvwnbDPlV_UqpM.jpeg" width="700">
|
| 18 |
|
| 19 |
---
|
|
|
|
| 21 |
## Installation
|
| 22 |
|
| 23 |
```bash
|
| 24 |
+
pip install transformers pillow torch
|
| 25 |
```
|
| 26 |
|
| 27 |
## Usage
|
|
|
|
| 28 |
|
| 29 |
+
StyleID is best suited for single-face images. A rough center crop near the face is recommended for better performance. It is not intended for use with multiple faces or faces too small to recognize.
|
| 30 |
+
|
| 31 |
+
```python
|
| 32 |
import torch
|
| 33 |
from transformers import CLIPModel, CLIPProcessor
|
| 34 |
from PIL import Image
|
| 35 |
|
| 36 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 37 |
|
| 38 |
+
# Load model and processor
|
| 39 |
model = CLIPModel.from_pretrained("kwanY/styleid").to(device)
|
| 40 |
processor = CLIPProcessor.from_pretrained("kwanY/styleid")
|
| 41 |
|
| 42 |
+
# Prepare image
|
| 43 |
+
img_path = "example.jpg"
|
| 44 |
img = Image.open(img_path).convert("RGB")
|
| 45 |
inputs = processor(images=img, return_tensors="pt").to(device)
|
| 46 |
|
| 47 |
+
# Extract features
|
| 48 |
with torch.no_grad():
|
| 49 |
emb = model.get_image_features(**inputs)
|
| 50 |
emb = emb / emb.norm(dim=-1, keepdim=True) # optional but recommended
|
| 51 |
```
|
| 52 |
|
| 53 |
+
## Intended Uses
|
| 54 |
+
|
| 55 |
+
- Identity similarity comparison
|
| 56 |
+
- Image retrieval
|
| 57 |
+
- Stylized identity evaluation
|
| 58 |
+
- Identity-aware conditioning for generative models
|
| 59 |
+
- Research on face recognition under domain shift and stylization
|
| 60 |
+
|
| 61 |
+
## License and Usage Notice
|
| 62 |
+
|
| 63 |
+
- StyleID is released for non-commercial research use.
|
| 64 |
+
- Do not use FFHQ-derived data for biometric human recognition.
|
| 65 |
+
|
| 66 |
+
## Citation
|
| 67 |
+
|
| 68 |
+
If you find this work useful, please cite the paper:
|
| 69 |
+
|
| 70 |
+
```bibtex
|
| 71 |
+
@article{yun2026styleid,
|
| 72 |
+
title={StyleID: A Perception-Aware Dataset and Metric for Stylization-Agnostic Facial Identity Recognition},
|
| 73 |
+
author={Yun, Kwan and Lee, Changmin and Jeong, Ayeong and Kim, Youngseo and Lee, Seungmi and Noh, Junyong},
|
| 74 |
+
journal={arXiv preprint arXiv:2604.21689},
|
| 75 |
+
year={2026}
|
| 76 |
+
}
|
| 77 |
+
```
|