Upload README.md
Browse files
README.md
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: creativeml-openrail-m
|
3 |
+
tags:
|
4 |
+
- pytorch
|
5 |
+
- diffusers
|
6 |
+
- stable-diffusion
|
7 |
+
- text-to-image
|
8 |
+
- diffusion-models-class
|
9 |
+
- dreambooth-hackathon
|
10 |
+
- landscape
|
11 |
+
pipeline_tag: other
|
12 |
+
widget:
|
13 |
+
- text: isometric scspace terrain
|
14 |
+
datasets:
|
15 |
+
- wdcqc/starcraft-remastered-melee-maps
|
16 |
+
---
|
17 |
+
|
18 |
+
# DreamBooth model for Starcraft:Remastered terrain
|
19 |
+
|
20 |
+
This is a Stable Diffusion model fine-tuned on Starcraft terrain images with DreamBooth. It can be used by adding the `instance_prompt`: **isometric starcraft <tileset> terrain**
|
21 |
+
|
22 |
+
The `<tileset>` should be one of `ashworld`, `badlands`, `desert`, `ice`, `jungle`, `platform`, `twilight` or `installation`, which corresponds to Starcraft terrain tilesets.
|
23 |
+
|
24 |
+
It was trained on 32x32 terrain images from 1,808 melee maps including original Blizzard maps and those downloaded from Battle.net, scmscx.com and broodwarmaps.net.
|
25 |
+
|
26 |
+
Run it on Huggingface Spaces:
|
27 |
+
|
28 |
+
https://huggingface.co/spaces/wdcqc/wfd
|
29 |
+
|
30 |
+
Or use this notebook on Colab:
|
31 |
+
|
32 |
+
https://colab.research.google.com/github/wdcqc/WaveFunctionDiffusion/blob/remaster/colab/WaveFunctionDiffusion_Demo.ipynb
|
33 |
+
|
34 |
+
In addition to Dreambooth, a custom VAE model (`AutoencoderTile`) for each tileset is trained to decode the latents to tileset probabilities ("waves") and generate as Starcraft maps.
|
35 |
+
|
36 |
+
A WFC Guidance, inspired by the Wave Function Collapse algorithm, is also added to the pipeline. For more information about guidance please see this page: [Fine-Tuning, Guidance and Conditioning](https://github.com/huggingface/diffusion-models-class/tree/main/unit2)
|
37 |
+
|
38 |
+
This model was created as part of the DreamBooth Hackathon. Visit the [organisation page](https://huggingface.co/dreambooth-hackathon) for instructions on how to take part!
|
39 |
+
|
40 |
+
## Description
|
41 |
+
|
42 |
+
|
43 |
+
This is a Stable Diffusion model fine-tuned on starcraft terrain images for the landscape theme.
|
44 |
+
|
45 |
+
GitHub: https://github.com/wdcqc/WaveFunctionDiffusion
|
46 |
+
|
47 |
+
|
48 |
+
## Usage
|
49 |
+
|
50 |
+
First clone the git repository:
|
51 |
+
|
52 |
+
```bash
|
53 |
+
git clone https://github.com/wdcqc/WaveFunctionDiffusion.git
|
54 |
+
```
|
55 |
+
|
56 |
+
Then create a Jupyter notebook under the repository folder:
|
57 |
+
|
58 |
+
```python
|
59 |
+
# Load pipeline
|
60 |
+
from wfd.wf_diffusers import WaveFunctionDiffusionPipeline
|
61 |
+
from wfd.wf_diffusers import AutoencoderTile
|
62 |
+
from wfd.scmap import get_tile_data, get_tileset_keyword
|
63 |
+
|
64 |
+
# Tilesets: ashworld, badlands, desert, ice, jungle, platform, twilight, install
|
65 |
+
tileset = "ice"
|
66 |
+
|
67 |
+
# The data files are located in wfd/scmap/tile_data/wfc
|
68 |
+
wfc_data_path = get_tile_data("wfc/{}_64x64.npz".format(tileset))
|
69 |
+
|
70 |
+
# Use CUDA (otherwise it will take 15 minutes)
|
71 |
+
device = "cuda"
|
72 |
+
|
73 |
+
tilenet = AutoencoderTile.from_pretrained(
|
74 |
+
"wdcqc/starcraft-terrain-64x64",
|
75 |
+
subfolder="tile_vae_{}".format(tileset)
|
76 |
+
).to(device)
|
77 |
+
pipeline = WaveFunctionDiffusionPipeline.from_pretrained(
|
78 |
+
"wdcqc/starcraft-terrain-64x64",
|
79 |
+
tile_vae = tilenet,
|
80 |
+
wfc_data_path = wfc_data_path
|
81 |
+
)
|
82 |
+
pipeline.to(device)
|
83 |
+
|
84 |
+
# Double speed (only works for CUDA)
|
85 |
+
pipeline.set_precision("half")
|
86 |
+
|
87 |
+
# Generate pipeline output
|
88 |
+
# need to include the dreambooth keywords "isometric starcraft {tileset_keyword} terrain"
|
89 |
+
tileset_keyword = get_tileset_keyword(tileset)
|
90 |
+
pipeline_output = pipeline(
|
91 |
+
"lost temple, isometric starcraft {} terrain".format(tileset_keyword),
|
92 |
+
num_inference_steps = 50,
|
93 |
+
guidance_scale = 3.5,
|
94 |
+
wfc_guidance_start_step = 20,
|
95 |
+
wfc_guidance_strength = 5,
|
96 |
+
wfc_guidance_final_steps = 20,
|
97 |
+
wfc_guidance_final_strength = 10,
|
98 |
+
)
|
99 |
+
image = pipeline_output.images[0]
|
100 |
+
|
101 |
+
# Display raw generated image
|
102 |
+
from IPython.display import display
|
103 |
+
display(image)
|
104 |
+
|
105 |
+
# Display generated image as tiles
|
106 |
+
wave = pipeline_output.waves[0]
|
107 |
+
tile_result = wave.argmax(axis=2)
|
108 |
+
|
109 |
+
from wfd.scmap import demo_map_image
|
110 |
+
display(demo_map_image(tile_result, wfc_data_path = wfc_data_path))
|
111 |
+
|
112 |
+
# Generate map file
|
113 |
+
from wfd.scmap import tiles_to_scx
|
114 |
+
import random, time
|
115 |
+
|
116 |
+
tiles_to_scx(
|
117 |
+
tile_result,
|
118 |
+
"outputs/{}_{}_{:04d}.scx".format(tileset, time.strftime("%Y%m%d_%H%M%S"), random.randint(0, 1e4)),
|
119 |
+
wfc_data_path = wfc_data_path
|
120 |
+
)
|
121 |
+
|
122 |
+
# Open the generated map file in `outputs` folder with Scmdraft 2
|
123 |
+
```
|