Skip to content

Commit

Permalink
Merge pull request #342 from NicholasCao/master
Browse files Browse the repository at this point in the history
Add implementation of BeautifulPrompt and X-STA
  • Loading branch information
chywang committed Oct 20, 2023
2 parents cff7463 + 74e6782 commit 6808d47
Show file tree
Hide file tree
Showing 75 changed files with 16,511 additions and 0 deletions.
152 changes: 152 additions & 0 deletions examples/BeautifulPrompt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/
docs/.build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# IDE
.idea/
.vscode/

# macos
*.DS_Store
#data/

docs/.build

# pytorch checkpoint
*.pt

# wandb log
example/wandb/

outputs/*
logs/*
data/*
!data/README.md
wandb/*
43 changes: 43 additions & 0 deletions examples/BeautifulPrompt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# BeautifulPrompt
This project is implemented for the EMNLP Industry Track 2023 paper: "BeautifulPrompt: Towards Automatic Prompt Engineering for Text-to-Image Synthesis". Our code is based on pytorch and huggingface transformers.

## Data & Models
We released our collected [dataset](https://atp-modelzoo-sh.oss-cn-shanghai.aliyuncs.com/release/tutorials/BeautifulPrompt/data.json), which includes prompt pairs and various scores, and also released a more extensive [rm_aesthetic dataset](https://atp-modelzoo-sh.oss-cn-shanghai.aliyuncs.com/release/tutorials/BeautifulPrompt/rm_aesthetic.json).

We released the following models:
- [alibaba-pai/pai-bloom-1b1-text2prompt-sd](https://huggingface.co/alibaba-pai/pai-bloom-1b1-text2prompt-sd)
- [alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2](https://huggingface.co/alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2)

## Run
### Installation
```bash
conda create -n trlx python=3.10
conda activate trlx

pip install -e .
pip install tensorboardX==2.6.0
```

### Training
```bash
# Step 1
bash scripts/sft.sh
# Step 2
bash scripts/rm_aes.sh
bash scripts/rm_ps.sh
# Step 3
bash scripts/ppo.sh
```

### Evaluation
```bash
pip install pillow
pip install image-reward==1.2
pip install git+https://github.com/openai/CLIP
pip install diffusers

bash scripts/eval.sh
```

## Acknowledgement
This repo benefits from [trlx](https://github.com/CarperAI/trlx). Thanks for their wonderful works.
Loading

0 comments on commit 6808d47

Please sign in to comment.