• Stars
    star
    571
  • Rank 78,127 (Top 2 %)
  • Language
    Jupyter Notebook
  • License
    Other
  • Created over 2 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Implementation of disco-diffusion wrapper that could run on your own GPU with batch text input.

disco-diffusion-wrapper

Implementation of a disco diffusion wrapper that could run on your own GPU with a batch of input text.

Based on this work, an AI painting website (https://6pen.art/) was built, you may have a try.

What this repo did

1.Separate the model loading and model inference parts of the initial code. Now you can use it like:

# init and load pretrain model.
disco = DiscoDiffusion()
# infer
disco.draw(text, ...)

2.Use deepL to preprocess the text, so that you can use any language you like to draw. The default language pair is from Chinese->English(ZH->EN-US),you can change it in run.py or run_batch.py

def translate(text, source_lang="ZH", target_lang="EN-US"):
    res = translator.translate_text(text, source_lang="ZH", target_lang="EN-US")
    return res

You can also turn-off text translation by setting USE_TRANSLATE=False so that you don't need the DeepL authKey.

3.Batch generating & saving. As the loading part and the inferring part is seperated, you do not need to load pretrain model again for a new sentence. This reduces a bunch of time.

cd disco-diffusion-wrapper/wrapper
# create and fill the sentence.list
python run_batch.py

The output images is saved by the name of the origin text, so you can easily find it even after a deepL.

Usage

git clone [email protected]:mazzzystar/disco-diffusion-wrapper.git
cd disco-diffusion-wrapper/
conda create --name disco
conda activate disco
pip install -r requirements.txt
cd wrapper/

# download pretrain model checkpoints
"""If this step is slow, you can download these model mannually from urls in the 
code of mutils.py, then put these checkpoints in the corresponding folder."""
python mutils.py

# Get your deepL API key, then add it to your run.py or batch_run.py to replace:
USE_TRANSLATE=True
auth_key = ""

# generated image by one sentence
python run.py "一行白鹭上青天"

# batch generation
touch sentence.list
# fill your text in, one by a line.
python run_batch.py

Samples

Below are some samples generated using this repo.

半亩方塘一鉴开,天光云影共徘徊,水墨画

雪山,平原,幽鬼军队在夜里打着荧光绿色的火把前行,抽象画,Trending on artstation

躺在废墟中的玻璃鲸鱼,抽象画

明月松间照,清泉石上流,中国画

Elf Castle

山随平野尽,江入大荒流,Trending on artstation

You can download all our Chinese poem generating results from here.

If you use this project and produced some interesting results, submissions are welcomed.

Problems

As it's for fun, I did not look much into the details, and deleted many features(such as VR/3D/Video ...) to make me faster and more clear on the project resonctruction. It's awesome if you're interested in restoring the original function, PR is wellcomed.

More Repositories

1

Queryable

Run OpenAI's CLIP model on iOS to search photos.
Swift
2,430
star
2

tinymind

Tinymind - Write and sync your blog & thoughts with GitHub
TypeScript
617
star
3

randomCNN-voice-transfer

Audio style transfer with shallow random parameters CNN.
Python
375
star
4

PodFind

Find what podcasters think of new things: GPT-4, SVB, etc.
JavaScript
149
star
5

Proxy

A simple tool for fetching usable proxies from several websites.
Python
125
star
6

BaiduCrawler

Sample of using proxies to crawl baidu search results.
Python
118
star
7

api-usage

Track your OpenAI API token usage & cost.
HTML
58
star
8

WaveGAN-pytorch

PyTorch implementation of " Synthesizing Audio with Generative Adversarial Networks"
Python
57
star
9

teach-show-consult

Teach ChatGPT the Alda music programming language, show it some superb code, and consult with it to compose a melody.
Python
47
star
10

QLearningMouse

Cat-and-Mouse game with Reinforcement Learning (Q-Learning).
Python
24
star
11

make-CelebA-HQ

Supposed you've downloaded CelebA & CelebA-HQ dataset, and want to get HQ images from them.
Python
15
star
12

Manzarek

A tiny bot reposts blind date information from website fanfou.
Python
11
star
13

Disentangled-Sequential-Autoencoder

PyTorch Implementation of Disentangled Sequential Autoencoder
Jupyter Notebook
8
star
14

Focus

Chrome Extension: One-click to batch open websites, double-click to close them.
JavaScript
8
star
15

N-Grams-novel

An English & Chinese novel generator based on N-Grams.
Python
4
star
16

DrQAChinese

Python
3
star
17

mazz.github.io

HTML
1
star
18

mazzzystar.github.io

HTML
1
star
19

MusicGAN

Generate long-term "structure" dependency raw piano audio, result: https://soundcloud.com/mazzzystar/sets/only-1-discriminator-to-control-both-local-long-term
Python
1
star