---
title: stylebooth
canonical_url: "https://www.modelscope.cn/models/iic/stylebooth"
md_url: "https://www.modelscope.cn/models/iic/stylebooth.md"
repository: iic/stylebooth
chinese_name: "stylebooth风格迁移模型"
last_updated: 2024-06-25
license: "Apache License 2.0"
pipeline_tag: image-style-transfer
tasks:
  - image-style-transfer
library_name:
  - pytorch
frameworks:
  - Pytorch
downloads: 454
stars: 6
---

# stylebooth

> stylebooth - iic 在 ModelScope 开源的模型。StyleBooth: Image Style Editing with Multimodal Instruction

iic/stylebooth 是 ModelScope 魔搭社区上的image-style-transfer模型，采用 Apache License 2.0 许可。

- **Repository**: iic/stylebooth
- **License**: Apache License 2.0
- **Tasks**: image-style-transfer
- **Downloads**: 454
- **Stars**: 6
- **Last updated**: 2024-06-25

Source: https://www.modelscope.cn/models/iic/stylebooth

---

# StyleBooth: Image Style Editing with Multimodal Instruction


<video muted="true" autoplay="true" loop="true" height="480" src="https://www.modelscope.cn/api/v1/models/iic/stylebooth/repo?Revision=master&FilePath=public%2Fstylebooth.webm"></video>

[Project Home](https://ali-vilab.github.io/stylebooth-page/)

## StyleBooth Dataset and Model
You can download our dataset as a zip file at `stylebooth/datasets/stylebooth_dataset.zip`, and our model at `stylebooth/models/stylebooth-tb-5000-0.bin`.

## Run StyleBooth
There are 3 different ways to try StyleBooth:
- Code implementation: See model configuration and code based on [🪄SCEPTER](https://github.com/modelscope/scepter).

- Demo: Try 🖥️SCEPTER Studio. [Run Locally](https://github.com/modelscope/scepter/tree/main?tab=readme-ov-file#%EF%B8%8F-scepter-studio) or [Run HuggingFace Space](https://huggingface.co/spaces/modelscope/scepter_studio) or [Run ModelScope Studio](https://www.modelscope.cn/studios/iic/scepter_studio/summary). 

- Easy run:
Try the following example script to run StyleBooth modified from [tests/modules/test_diffusion_inference.py](https://github.com/modelscope/scepter/blob/main/tests/modules/test_diffusion_inference.py):

```python
# `pip install scepter>0.0.4` or
# clone newest SCEPTER and run `PYTHONPATH=./ python <this_script>` at the main branch root.
import os
import unittest

from PIL import Image
from torchvision.utils import save_image

from scepter.modules.inference.stylebooth_inference import StyleboothInference
from scepter.modules.utils.config import Config
from scepter.modules.utils.file_system import FS
from scepter.modules.utils.logger import get_logger


class DiffusionInferenceTest(unittest.TestCase):
    def setUp(self):
        print(('Testing %s.%s' % (type(self).__name__, self._testMethodName)))
        self.logger = get_logger(name='scepter')
        config_file = 'scepter/methods/studio/scepter_ui.yaml'
        cfg = Config(cfg_file=config_file)
        if 'FILE_SYSTEM' in cfg:
            for fs_info in cfg['FILE_SYSTEM']:
                FS.init_fs_client(fs_info)
        self.tmp_dir = './cache/save_data/diffusion_inference'
        if not os.path.exists(self.tmp_dir):
            os.makedirs(self.tmp_dir)

    def tearDown(self):
        super().tearDown()

    # uncomment this line to skip this module.
    # @unittest.skip('')
    def test_stylebooth(self):
        config_file = 'scepter/methods/studio/inference/edit/stylebooth_tb_pro.yaml'
        cfg = Config(cfg_file=config_file)
        diff_infer = StyleboothInference(logger=self.logger)
        diff_infer.init_from_cfg(cfg)

        output = diff_infer({'prompt': 'Let this image be in the style of sai-lowpoly'},
                            style_edit_image=Image.open('asset/images/inpainting_text_ref/ex4_scene_im.jpg'),
                            style_guide_scale_text=7.5,
                            style_guide_scale_image=1.5,
                            stylebooth_state=True)
        save_path = os.path.join(self.tmp_dir,
                                 'stylebooth_test_lowpoly_cute_dog.png')
        save_image(output['images'], save_path)


if __name__ == '__main__':
    unittest.main()
```
