boris commited on
Commit
27a3435
2 Parent(s): 783de86 a8c579f

Merge pull request #74 from borisdayma/feat-setup

Browse files
README.md CHANGED
@@ -26,8 +26,6 @@ Refer to [our report](https://wandb.ai/dalle-mini/dalle-mini/reports/DALL-E-mini
26
 
27
  ### Dependencies Installation
28
 
29
- The root folder and associated [`requirements.txt`](./requirements.txt) is only for the app.
30
-
31
  For development, use [`dev/requirements.txt`](dev/requirements.txt) or [`dev/environment.yaml`](dev/environment.yaml).
32
 
33
  ### Training of VQGAN
 
26
 
27
  ### Dependencies Installation
28
 
 
 
29
  For development, use [`dev/requirements.txt`](dev/requirements.txt) or [`dev/environment.yaml`](dev/environment.yaml).
30
 
31
  ### Training of VQGAN
app/app.py CHANGED
@@ -1,7 +1,6 @@
1
  #!/usr/bin/env python
2
  # coding: utf-8
3
 
4
- import random
5
  from dalle_mini.backend import ServiceError, get_images_from_backend
6
 
7
  import streamlit as st
 
1
  #!/usr/bin/env python
2
  # coding: utf-8
3
 
 
4
  from dalle_mini.backend import ServiceError, get_images_from_backend
5
 
6
  import streamlit as st
app/dalle_mini DELETED
@@ -1 +0,0 @@
1
- ../dalle_mini/
 
 
app/gradio/dalle_mini DELETED
@@ -1 +0,0 @@
1
- ../../dalle_mini/
 
 
dev/README.md ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Development Instructions for TPU
2
+
3
+ ## Setup
4
+
5
+ - Apply to the [TRC program](https://sites.research.google/trc/) for free TPU credits if you're elligible.
6
+ - Follow the [Cloud TPU VM User's Guide](https://cloud.google.com/tpu/docs/users-guide-tpu-vm) to set up gcloud.
7
+ - Verify `gcloud config list`, in particular account, project & zone.
8
+ - Create a TPU VM per the guide and connect to it.
9
+
10
+ When needing a larger disk:
11
+
12
+ - Create a balanced persistent disk (SSD, so pricier than default HDD but much faster): `gcloud compute disks create DISK_NAME --size SIZE_IN_GB --type pd-balanced`
13
+ - Attach the disk to your instance by adding `--data-disk source=REF` per ["Adding a persistent disk to a TPU VM" guide](https://cloud.google.com/tpu/docs/setup-persistent-disk), eg `gcloud alpha compute tpus tpu-vm create INSTANCE_NAME --accelerator-type=v3-8 --version=v2-alpha --data-disk source=projects/tpu-toys/zones/europe-west4-a/disks/DISK_NAME`
14
+ - Format the partition as described in the guide.
15
+ - Make sure to set up automatic remount of disk at restart.
16
+
17
+ ## Connect VS Code
18
+
19
+ - Find external IP in the UI or with `gcloud alpha compute tpus tpu-vm describe INSTANCE_NAME`
20
+ - Verify you can connect in terminal with `ssh EXTERNAL_IP -i ~/.ssh/google_compute_engine`
21
+ - Add the same command as ssh host in VS Code.
22
+ - Check config file
23
+
24
+ ```
25
+ Host INSTANCE_NAME
26
+ HostName EXTERNAL_IP
27
+ IdentityFile ~/.ssh/google_compute_engine
28
+ ```
29
+
30
+ ## Environment configuration
31
+
32
+ ### Use virtual environments (optional)
33
+
34
+ We recommend using virtual environments (such as conda, venv or pyenv-virtualenv).
35
+
36
+ If you want to use `pyenv` and `pyenv-virtualenv`:
37
+
38
+ - Installation
39
+
40
+ - [Set up build environment](https://github.com/pyenv/pyenv/wiki#suggested-build-environment)
41
+ - Use [pyenv-installer](https://github.com/pyenv/pyenv-installer): `curl https://pyenv.run | bash`
42
+ - bash set-up:
43
+
44
+ ```bash
45
+ echo '\n'\
46
+ '# pyenv setup \n'\
47
+ 'export PYENV_ROOT="$HOME/.pyenv" \n'\
48
+ 'export PATH="$PYENV_ROOT/bin:$PATH" \n'\
49
+ 'eval "$(pyenv init --path)" \n'\
50
+ 'eval "$(pyenv init -)" \n'\
51
+ 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
52
+ ```
53
+
54
+ - Usage
55
+
56
+ - Install a python version: `pyenv install X.X.X`
57
+ - Create a virtual environment: `pyenv virtualenv 3.9.6 dalle_env`
58
+ - Activate: `pyenv activate dalle_env`
59
+
60
+ Note: you can auto-activate your environment at a location with `echo dalle_env >> .python-version`
61
+
62
+ ### Tools
63
+
64
+ - Git
65
+
66
+ - `git config --global user.email "name@domain.com"
67
+ - `git config --global user.name "First Last"
68
+
69
+ - Github CLI
70
+
71
+ - See [installation instructions](https://github.com/cli/cli/blob/trunk/docs/install_linux.md)
72
+ - `gh auth login`
73
+
74
+ - Direnv
75
+
76
+ - Install direnv: `sudo apt-get update && sudo apt-get install direnv`
77
+ - bash set-up:
78
+
79
+ ```bash
80
+ echo -e '\n'\
81
+ '# direnv setup \n'\
82
+ 'eval "$(direnv hook bash)" \n' >> ~/.bashrc
83
+ ```
84
+
85
+ ### Set up repo
86
+
87
+ - Clone repo: `gh repo clone borisdayma/dalle-mini`
88
+ - If using `pyenv-virtualenv`, auto-activate env: `echo dalle_env >> .python-version`
89
+
90
+ ## Environment
91
+
92
+ - Install the following (use it later to update our dev requirements.txt)
93
+
94
+ ```
95
+ requests
96
+ pillow
97
+ jupyterlab
98
+ ipywidgets
99
+
100
+ -e ../datasets[streaming]
101
+ -e ../transformers
102
+ -e ../webdataset
103
+
104
+ # JAX
105
+ --find-links https://storage.googleapis.com/jax-releases/libtpu_releases.html
106
+ jax[tpu]>=0.2.16
107
+ flax
108
+ ```
109
+
110
+ - `transformers-cli login`
111
+
112
+ ---
113
+
114
+ - set `HF_HOME="/mnt/disks/persist/cache/huggingface"` in `/etc/environment` and ensure you have required permissions, then restart.
115
+
116
+ ## Working with datasets or models
117
+
118
+ - Install [Git LFS](https://github.com/git-lfs/git-lfs/wiki/Installation)
119
+ - Clone a dataset without large files: `GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/datasets/.../...`
120
+ - Use a local [credential store](https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage) for caching credentials
121
+ - Track specific extentions: `git lfs track "*.ext"`
122
+ - See files tracked with LFS with `git lfs ls-files`
dev/inference/dalle_mini DELETED
@@ -1 +0,0 @@
1
- ../../dalle_mini
 
 
requirements.txt DELETED
@@ -1,2 +0,0 @@
1
- # Requirements for huggingface spaces
2
- streamlit>=0.84.2
 
 
 
setup.cfg ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [metadata]
2
+ name = dalle_mini
3
+ version = attr: dalle_mini.__version__
4
+ description = DALL·E mini - Generate images from a text prompt
5
+ long_description = file: README.md
6
+ long_description_content_type = text/markdown
7
+ url = https://github.com/borisdayma/dalle-mini
8
+ project_urls =
9
+ Bug Tracker = https://github.com/borisdayma/dalle-mini/issues
10
+
11
+ [options]
12
+ packages = find:
13
+ install_requires =
14
+ transformers
15
+ jax
16
+ flax
setup.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ from setuptools import setup
2
+
3
+ if __name__ == "__main__":
4
+ setup()