GithubHelp home page GithubHelp logo

sunnyanthony / creativetlab Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vt-cs-asl/conceptlab

0.0 0.0 0.0 3.57 MB

A fork of "ConceptLab: Creative Generation using Diffusion Prior Constraints" to do research in different method

Home Page: https://kfirgoldberg.github.io/ConceptLab/

License: MIT License

Python 100.00%

creativetlab's Introduction

ConceptLab: Creative Concept Generation using VLM-Guided Diffusion Prior Constraints

Elad Richardson, Kfir Goldberg, Yuval Alaluf, Daniel Cohen-Or
Tel Aviv University
Recent text-to-image generative models have enabled us to transform our words into vibrant, captivating imagery. The surge of personalization techniques that has followed has also allowed us to imagine unique concepts in new scenes. However, an intriguing question remains: How can we generate a new, imaginary concept that has never been seen before? In this paper, we present the task of creative text-to-image generation, where we seek to generate new members of a broad category (e.g., generating a pet that differs from all existing pets). We leverage the under-studied Diffusion Prior models and show that the creative generation problem can be formulated as an optimization process over the output space of the diffusion prior, resulting in a set of "prior constraints". To keep our generated concept from converging into existing members, we incorporate a question-answering Vision-Language Model (VLM) that adaptively adds new constraints to the optimization problem, encouraging the model to discover increasingly more unique creations. Finally, we show that our prior constraints can also serve as a strong mixing mechanism allowing us to create hybrids between generated concepts, introducing even more flexibility into the creative process.


New pets generated using ConceptLab. Each pair depicts a learned concept that was optimized to be novel and not match existing members of the pet category. Running our method with different seeds allows us to generate a variety of different brand-new concepts.

Description

Official implementation of our ConceptLab paper.

Setup

To create the conda environment needed to run the code, run the following command:

conda env create -f environment/env.yaml
conda activate ConceptLab

Alternatively, install the requirements from requirements.txt

Usage

Creative Generation


Sample text-guided creative generation results and edits obtained with ConceptLab.

Training a New Concept

To train a new concept of the pet category using the Adaptive Negatives scheme, run the following command:

python -m scripts.train --config configs/new_pet.yaml --output_dir=<output_dir>

Generating Images with a Trained Concept

To generate images from a trained concept, using some prompts e.g. ['a photo of a {}','a plush toy {}'] run the following command:

python -m scripts.infer --prompts="['a photo of a {}','a plush toy {}']" --output_dir <output_dir> --learned_embeds_path <learned_embeds_path.bin>

Creating Art Styles

To create an art style instead of an object use the following command python -m scripts.train --config configs/new_art.yaml --output_dir=<output_dir>

Evolutionary Generation


ConceptLab can be used to mix up generated concepts to iteratively learn new unique creations. This process can be repeated to create further "Generations", each one being a hybrid between the previous two.

Creating Parents Gallery

In order to define each parent in the evolution process, we first need to create a few (3-5) images of each. To do so, the following command can be used

python -m scripts.infer --prompts="['a photo of a {}']" --output_dir <output_dir> --learned_embeds_path <learned_embeds_path.bin> --samples_per_prompt=32

Select 3-5 examples that you like for each parent and place them in <parent1_dir> and <parent2_dir>.

To train the resulting concept, run the following command:

python -m scripts.train_evolution --parents_images_dirs="['<parent1_dir>','<parent2_dir>']" --initializer_token <initializer_token> --output_dir <output_dir> --mix_weights="[0.4,0.6]"

Concept Mixing


With ConceptLab, we can also form hybrid concepts by merging unique traits across multiple real concepts. This can be done by defining multiple positive concepts, allowing us to create unique creations such as a lobs-turtle, pine-melon, and more!

To mix 2 or more concepts, run the training script with the positives constraints, and no negative constraints:

python -m scripts.train --config configs/new_pet.yaml --output_dir=<output_dir> --live_negatives=False --positive_classes="['fish','panda']"

Acknowledgements

This code is builds on the code from the kandinsky2 library as well as the diffusers codebase.

Citation

If you use this code for your research, please cite the following work:

@misc{richardson2023conceptlab,
      title={ConceptLab: Creative Generation using Diffusion Prior Constraints}, 
      author={Elad Richardson and Kfir Goldberg and Yuval Alaluf and Daniel Cohen-Or},
      year={2023},
      eprint={2308.02669},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

creativetlab's People

Contributors

sunnyanthony avatar eladrich avatar yuval-alaluf avatar kfirgoldberg avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.