Thanks to visit codestin.com
Credit goes to github.com

Skip to content

WangWenhao0716/AnypatternStyle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anypattern helps artists

Another application of our paper "AnyPattern: Towards In-context Image Copy Detection"

The text-to-image model can be used to mimic the style of artwork with little cost, and this threatens the livelihoods and creative rights of artists. To help them protect their work, we treat an artist’s ‘style’ as a ‘pattern’ and generalize the trained pattern retrieval method to identify generated images with style mimicry.

image

Training

Please refer to the original repository of AnyPattern.

Demonstration

image

Installation

conda create -n style python=3.9
conda activate style
pip install torch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 --index-url https://download.pytorch.org/whl/cu118
pip install timm==0.4.12

Usage

import requests
import torch
from PIL import Image

from anypattern_style_extractor import preprocessor, create_model

model_name = 'vit_base_pattern'
weight_name = 'vit_ddpmm_8gpu_512_torch2_ap31_pattern.pth.tar'
model = create_model(model_name, weight_name)

url = "https://huggingface.co/datasets/WenhaoWang/AnyPattern/resolve/main/Irises.jpg"
image = Image.open(requests.get(url, stream=True).raw)
x = preprocessor(image).unsqueeze(0)

style_features = model.forward_features(x)  # => torch.Size([1, 768])
style_features_normalized = torch.nn.functional.normalize(style_features, p=2, dim=1)  # => torch.Size([1, 768])

Citation

@article{wang2025AnyPattern,
    title={AnyPattern: Towards In-context Image Copy Detection},
    author={Wang, Wenhao and Sun, Yifan and Tan, Zhentao and Yang, Yi},
    booktitle={International Journal of Computer Vision},
    year={2025},
}

Contact

If you have any questions, feel free to contact Wenhao Wang ([email protected]).

About

[IJCV 2025] The style extractor trained on AnyPattern

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages