百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

CSD

> 编程语言
开源

免责声明 我们目前正在调查上传的模型权重出现的问题,导致与报告的结果存在一些不一致。

197 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

免责声明 我们目前正在调查上传的模型权重出现的问题,导致与报告的结果存在一些不一致。

DISCLAIMER

We are currently investigating an issue with our uploaded model weights due to which there is some discrepancy with the reported numbers in the paper. We will update soon.

Measuring Style Similarity in Diffusion Models

Check out the paper here - arxiv.

Create and activate the environment

conda env create -f environment.yml
conda activate style

Download the pretrained weights for the CSD model

If you want to download the model directly, the CSD model (ViT-L) weights here. If you are using huggingface, the CSD model (ViT-L) is here.

Download the pretrained weights for the baseline models

You need these only if you want to test the baseline numbers. For CLIP and DINO, pretrained weights will be downloaded automatically. For SSCD and MoCo, please download the weights from the links below and put them in ./pretrainedmodels folder.

  • SSCD: resnet50
  • MoCO: ViT-B

Download the WikiArt dataset

WikiArt can be downloaded from here or here1

After dataset is downloaded please put ./wikiart.csv in the parent directory of the dataset. The final directory structure should look like this:

path/to/WikiArt
├── wikiart
    ├── Abstract_Expressionism
        ├── .jpg
    ├── ...
└── wikiart.csv

Also, make sure that you add a column path in the wikiart.csv file which contains the absolute path to the image.

Generate the embeddings

Once WikiArt dataset is set up, you can generate the CSD embeddings by running the following command. Please adjust the --data-dir and --embed_dir accordingly. You should also adjust the batch size --b and number of workers --j according to your machine. The command to generate baseline embeddings is same, you just need to change the --pt_style with any of the following: clip, dino, sscd, moco.

angular2html
python main_sim.py --dataset wikiart -a vit_large --pt_style csd --feattype normal --world-size 1 
--dist-url tcp://localhost:6001 -b 128 -j 8 --embed_dir ./embeddings --data-dir 
--model_path 

Evaluate

Once you've generated the embeddings, run the following command:

angular2html
python search.py --mode artist --dataset wikiart --chunked --query-chunk-dir  
    --database-chunk-dir  --topk 1 10 100 1000 --method IP --data-dir 

Train CSD on LAION-Styles

You can also train style descriptors for your own datasets. A sample code for training on LAION-styles dataset is provided below.

We have started to release the Contra-Styles (referred to as LAION-Styles in the paper) dataset. The dataset is available here and will keep getting updated over the next few days as we are running profanity checks through NSFW and PhotoDNA. We will update here once the dataset has been completely uploaded.

bash
export PYTHONPATH="$PWD:$PYTHONPATH"

torchrun --standalone --nproc_per_node=4 CSD/train_csd.py --arch vit_base -j 8 -b 32 --maxsize 512 --resume_if_available --eval_k 1 10 100 --use_fp16 --use_distributed_loss --train_set laion_dedup --train_path  --eval_path   --output_dir 

Pending items

We will soon release the code to compute the artists' prototypical style representations and compute similarity score against any given generation. ETA end of June'24.

Cite us

@article{somepalli2024measuring,
  title={Measuring Style Similarity in Diffusion Models},
  author={Somepalli, Gowthami and Gupta, Anubhav and Gupta, Kamal and Palta, Shramay and Goldblum, Micah and Geiping, Jonas and Shrivastava, Abhinav and Goldstein, Tom},
  journal={arXiv preprint arXiv:2404.01292},
  year={2024}
}

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Python

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言