boris commited on
Commit
b78c972
2 Parent(s): 6e84403 ecf5f29

Merge branch 'main' of https://github.com/borisdayma/dalle-mini into feat-setup

Browse files
.github/workflows/sync_to_hub_debug.yml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Deploy to debug app
2
+
3
+ on:
4
+ # to run this workflow manually from the Actions tab
5
+ workflow_dispatch:
6
+
7
+ jobs:
8
+ sync-to-hub-debug:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ with:
13
+ fetch-depth: 0
14
+ - name: Push to hub
15
+ env:
16
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
17
+ run: git push --force https://boris:$HF_TOKEN@huggingface.co/spaces/flax-community/dalle-mini-debug +HEAD:main
CITATION.cff ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # YAML 1.2
2
+ ---
3
+ abstract: "DALL·E mini is a JAX/Flax reimplementation of OpenAI's DALL·E that requires much smaller hardware resources. By simplifying the architecture and model memory requirements, as well as leveraging open-source code and pre-trained models, we were able to create a model that is 27 times smaller than the original DALL·E and train it on a single TPU v3-8 for only 3 days. DALL·E mini achieves impressive results, albeit of a lower quality than the original system. It can be used for exploration and further experimentation on commodity hardware."
4
+ authors:
5
+ -
6
+ family-names: Dayma
7
+ given-names: Boris
8
+ -
9
+ family-names: Patil
10
+ given-names: Suraj
11
+ -
12
+ family-names: Cuenca
13
+ given-names: Pedro
14
+ -
15
+ family-names: Saifullah
16
+ given-names: Khalid
17
+ -
18
+ family-names: Abraham
19
+ given-names: Tanishq
20
+ -
21
+ family-names: "Lê Khắc"
22
+ given-names: "Phúc"
23
+ -
24
+ family-names: Melas
25
+ given-names: Luke
26
+ -
27
+ family-names: Ghosh
28
+ given-names: Ritobrata
29
+ cff-version: "1.1.0"
30
+ date-released: 2021-07-29
31
+ identifiers:
32
+ keywords:
33
+ - dalle
34
+ - "text-to-image generation"
35
+ - transformer
36
+ - "zero-shot"
37
+ - JAX
38
+ license: "Apache-2.0"
39
+ doi: 10.5281/zenodo.5146400
40
+ message: "If you use this project, please cite it using these metadata."
41
+ repository-code: "https://github.com/borisdayma/dalle-mini"
42
+ title: "DALL·E Mini"
43
+ version: "v0.1-alpha"
44
+ ...
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
  title: DALL·E mini
3
  emoji: 🥑
4
- colorFrom: red
5
- colorTo: purple
6
  sdk: streamlit
7
  app_file: app/app.py
8
  pinned: false
@@ -16,7 +16,7 @@ _Generate images from a text prompt_
16
 
17
  Our logo was generated with DALL·E mini using the prompt "logo of an armchair in the shape of an avocado".
18
 
19
- You can create your own pictures with [the demo](https://huggingface.co/spaces/flax-community/dalle-mini) (temporarily in beta on Huging Face Spaces but soon to be open to all).
20
 
21
  ## How does it work?
22
 
@@ -52,7 +52,16 @@ To generate sample predictions and understand the inference pipeline step by ste
52
 
53
  [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/borisdayma/dalle-mini/blob/main/dev/inference/inference_pipeline.ipynb)
54
 
55
- ## Where does the logo come from?
 
 
 
 
 
 
 
 
 
56
 
57
  The "armchair in the shape of an avocado" was used by OpenAI when releasing DALL·E to illustrate the model's capabilities. Having successful predictions on this prompt represents a big milestone to us.
58
 
@@ -70,4 +79,66 @@ The "armchair in the shape of an avocado" was used by OpenAI when releasing DALL
70
  ## Acknowledgements
71
 
72
  - 🤗 Hugging Face for organizing [the FLAX/JAX community week](https://github.com/huggingface/transformers/tree/master/examples/research_projects/jax-projects)
73
- - Google Cloud team for providing access to TPU's
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  title: DALL·E mini
3
  emoji: 🥑
4
+ colorFrom: yellow
5
+ colorTo: green
6
  sdk: streamlit
7
  app_file: app/app.py
8
  pinned: false
 
16
 
17
  Our logo was generated with DALL·E mini using the prompt "logo of an armchair in the shape of an avocado".
18
 
19
+ You can create your own pictures with [the demo](https://huggingface.co/spaces/flax-community/dalle-mini).
20
 
21
  ## How does it work?
22
 
 
52
 
53
  [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/borisdayma/dalle-mini/blob/main/dev/inference/inference_pipeline.ipynb)
54
 
55
+ ## FAQ
56
+
57
+ ### Where to find the latest models?
58
+
59
+ Trained models are on 🤗 Model Hub:
60
+
61
+ - [VQGAN-f16-16384](https://huggingface.co/flax-community/vqgan_f16_16384) for encoding/decoding images
62
+ - [DALL·E mini](https://huggingface.co/flax-community/dalle-mini) for generating images from a text prompt
63
+
64
+ ### Where does the logo come from?
65
 
66
  The "armchair in the shape of an avocado" was used by OpenAI when releasing DALL·E to illustrate the model's capabilities. Having successful predictions on this prompt represents a big milestone to us.
67
 
 
79
  ## Acknowledgements
80
 
81
  - 🤗 Hugging Face for organizing [the FLAX/JAX community week](https://github.com/huggingface/transformers/tree/master/examples/research_projects/jax-projects)
82
+ - Google [TPU Research Cloud (TRC) program](https://sites.research.google/trc/) for providing computing resources
83
+ - [Weights & Biases](https://wandb.com/) for providing the infrastructure for experiment tracking and model management
84
+
85
+ ## Citing DALL·E mini
86
+
87
+ If you find DALL·E mini useful in your research or wish to refer, please use the following BibTeX entry.
88
+
89
+ ```
90
+ @misc{Dayma_DALL·E_Mini_2021,
91
+ author = {Dayma, Boris and Patil, Suraj and Cuenca, Pedro and Saifullah, Khalid and Abraham, Tanishq and Lê Khắc, Phúc and Melas, Luke and Ghosh, Ritobrata},
92
+ doi = {10.5281/zenodo.5146400},
93
+ month = {7},
94
+ title = {DALL·E Mini},
95
+ url = {https://github.com/borisdayma/dalle-mini},
96
+ year = {2021}
97
+ }
98
+ ```
99
+
100
+ ## References
101
+
102
+ ```
103
+ @misc{ramesh2021zeroshot,
104
+ title={Zero-Shot Text-to-Image Generation},
105
+ author={Aditya Ramesh and Mikhail Pavlov and Gabriel Goh and Scott Gray and Chelsea Voss and Alec Radford and Mark Chen and Ilya Sutskever},
106
+ year={2021},
107
+ eprint={2102.12092},
108
+ archivePrefix={arXiv},
109
+ primaryClass={cs.CV}
110
+ }
111
+ ```
112
+
113
+ ```
114
+ @misc{esser2021taming,
115
+ title={Taming Transformers for High-Resolution Image Synthesis},
116
+ author={Patrick Esser and Robin Rombach and Björn Ommer},
117
+ year={2021},
118
+ eprint={2012.09841},
119
+ archivePrefix={arXiv},
120
+ primaryClass={cs.CV}
121
+ }
122
+ ```
123
+
124
+ ```
125
+ @misc{lewis2019bart,
126
+ title={BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension},
127
+ author={Mike Lewis and Yinhan Liu and Naman Goyal and Marjan Ghazvininejad and Abdelrahman Mohamed and Omer Levy and Ves Stoyanov and Luke Zettlemoyer},
128
+ year={2019},
129
+ eprint={1910.13461},
130
+ archivePrefix={arXiv},
131
+ primaryClass={cs.CL}
132
+ }
133
+ ```
134
+
135
+ ```
136
+ @misc{radford2021learning,
137
+ title={Learning Transferable Visual Models From Natural Language Supervision},
138
+ author={Alec Radford and Jong Wook Kim and Chris Hallacy and Aditya Ramesh and Gabriel Goh and Sandhini Agarwal and Girish Sastry and Amanda Askell and Pamela Mishkin and Jack Clark and Gretchen Krueger and Ilya Sutskever},
139
+ year={2021},
140
+ eprint={2103.00020},
141
+ archivePrefix={arXiv},
142
+ primaryClass={cs.CV}
143
+ }
144
+ ```
app/app.py CHANGED
@@ -55,12 +55,31 @@ st.subheader('Generate images from text')
55
 
56
  prompt = st.text_input("What do you want to see?")
57
 
58
- #TODO: I think there's an issue where we can't run twice the same inference (not due to caching) - may need to use st.form
59
-
60
  DEBUG = False
61
  if prompt != "" or (should_run_again and prompt != ""):
62
  container = st.empty()
63
- container.markdown(f"Generating predictions for: **{prompt}**")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
  try:
66
  backend_url = st.secrets["BACKEND_SERVER"]
 
55
 
56
  prompt = st.text_input("What do you want to see?")
57
 
58
+ test = st.empty()
 
59
  DEBUG = False
60
  if prompt != "" or (should_run_again and prompt != ""):
61
  container = st.empty()
62
+ # The following mimics `streamlit.info()`.
63
+ # I tried to get the secondary background color using `components.streamlit.config.get_options_for_section("theme")["secondaryBackgroundColor"]`
64
+ # but it returns None.
65
+ container.markdown(f"""
66
+ <style> p {{ margin:0 }} div {{ margin:0 }} </style>
67
+ <div data-stale="false" class="element-container css-1e5imcs e1tzin5v1">
68
+ <div class="stAlert">
69
+ <div role="alert" data-baseweb="notification" class="st-ae st-af st-ag st-ah st-ai st-aj st-ak st-g3 st-am st-b8 st-ao st-ap st-aq st-ar st-as st-at st-au st-av st-aw st-ax st-ay st-az st-b9 st-b1 st-b2 st-b3 st-b4 st-b5 st-b6">
70
+ <div class="st-b7">
71
+ <div class="css-whx05o e13vu3m50">
72
+ <div data-testid="stMarkdownContainer" class="css-1ekf893 e16nr0p30">
73
+ <img src="https://raw.githubusercontent.com/borisdayma/dalle-mini/main/app/img/loading.gif" width="30"/>
74
+ Generating predictions for: <b>{prompt}</b>
75
+ </div>
76
+ </div>
77
+ </div>
78
+ </div>
79
+ </div>
80
+ </div>
81
+ <small><i>Predictions may take up to 40s under high load. Please stand by.</i></small>
82
+ """, unsafe_allow_html=True)
83
 
84
  try:
85
  backend_url = st.secrets["BACKEND_SERVER"]
app/img/loading.gif ADDED
dev/requirements.txt CHANGED
@@ -1,10 +1,8 @@
1
- # Note: install with the following command:
2
- # pip install -r requirements.txt -f https://storage.googleapis.com/jax-releases/libtpu_releases.html
3
- # Otherwise it won't find the appropriate libtpu_nightly
4
  requests
 
5
  jax[tpu]>=0.2.16
6
- -e git+https://github.com/huggingface/transformers.git@master#egg=transformers
7
- -e git+https://github.com/huggingface/datasets.git@master#egg=datasets
8
  flax
9
  jupyter
10
  wandb
 
 
 
 
1
  requests
2
+ -f https://storage.googleapis.com/jax-releases/libtpu_releases.html
3
  jax[tpu]>=0.2.16
4
+ transformers
5
+ datasets
6
  flax
7
  jupyter
8
  wandb