Views
No views yet
class-images using free tier Colab, this will take 2-3 hours for 300 images. Once complete, you have 2 options, create the folder/root/.keras/datasets/class-images and copy the images to that directory, or create a tar.gz file and download the files for backup using the snippit below. Downloading the file will save you the compute of having to redo it again as it can simply be uploaded into the contents folder at a later time. You can collect the images for my_images into a folder in either PNG or JPG format, and upload the TAR.GZ version of the folder containing the images.1import glob
2import tarfile
3
4output_filename = "class-images.tar.gz"
5with tarfile.open(output_filename, "w:gz") as tar:
6 for file in glob.glob('class-images/*'):
7 tar.write(file)
8tf.keras.util.get_file with a tar.gz file located on your running VM you will need instance_images_root = tf.keras.utils.get_file(origin="file:///LOCATION_TO_TARGZ_FILE/my_images.tar.gz",untar=True) get_util - Tensorflow Docs. The command, in my case, places the files in '/root/.keras/datasets/my_images'. This will not work. The following work around resolved the issue:1# From within the Colab Notebook
2!mkdir /root/.keras/datasets/class-images
3!mkdir /root/.keras/datasets/my_images
4!cp /root/.keras/datasets/my_images.tar.gz /root/.keras/datasets/my_images/
5!cp /root/.keras/datasets/class-images.tar.gz /root/.keras/datasets/class-images/
6!tar -xvzf /root/.keras/datasets/class-images/class-images.tar.gz -C /root/.keras/datasets/class-images
7!tar -xvzf /root/.keras/datasets/my_images/my_images.tar.gz -C /root/.keras/datasets/my_imagesmy_images will improve the results. Current results used 10, but 20-30 is recommended based on Implementation of DreamBooth using KerasCV and TensorFlow - Notes on preparing data for DreamBooth training of faces.python -m pip install tensorflow==2.11 instead of python -m pip install tensorflow as 2.12 will be downloaded by default and there will be a CUDA version mismatch, causing computation to occur on the CPU instead of the GPU. A second note is setting export XLA_FLAGS=--xla_gpu_cuda_data_dir=/usr/lib/cuda and export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/ from a terminal will not transfer to a notebook. Be sure to set the environment variables in the jupyter notbook to enable the proper CUDA libraries to be used otherwise the GPU will not be accessable. %env MY_ENV_VAR=value can help and must be the first code block of the notebook.



| Hyperparameters | Value |
|---|---|
| inner_optimizer.class_name | Custom>RMSprop |
| inner_optimizer.config.name | RMSprop |
| inner_optimizer.config.weight_decay | None |
| inner_optimizer.config.clipnorm | None |
| inner_optimizer.config.global_clipnorm | None |
| inner_optimizer.config.clipvalue | None |
| inner_optimizer.config.use_ema | False |
| inner_optimizer.config.ema_momentum | 0.99 |
| inner_optimizer.config.ema_overwrite_frequency | 100 |
| inner_optimizer.config.jit_compile | True |
| inner_optimizer.config.is_legacy_optimizer | False |
| inner_optimizer.config.learning_rate | 0.0010000000474974513 |
| inner_optimizer.config.rho | 0.9 |
| inner_optimizer.config.momentum | 0.0 |
| inner_optimizer.config.epsilon | 1e-07 |
| inner_optimizer.config.centered | False |
| dynamic | True |
| initial_scale | 32768.0 |
| dynamic_growth_steps | 2000 |
| training_precision | mixed_float16 |

1
2@online{ruizDreamBoothFineTuning2023,
3 title = {{{DreamBooth}}: {{Fine Tuning Text-to-Image Diffusion Models}} for {{Subject-Driven Generation}}},
4 shorttitle = {{{DreamBooth}}},
5 author = {Ruiz, Nataniel and Li, Yuanzhen and Jampani, Varun and Pritch, Yael and Rubinstein, Michael and Aberman, Kfir},
6 date = {2023-03-15},
7 number = {arXiv:2208.12242},
8 eprint = {arXiv:2208.12242},
9 eprinttype = {arxiv},
10 url = {http://arxiv.org/abs/2208.12242},
11 urldate = {2023-03-26},
12 abstract = {Large text-to-image models achieved a remarkable leap in the evolution of AI, enabling high-quality and diverse synthesis of images from a given text prompt. However, these models lack the ability to mimic the appearance of subjects in a given reference set and synthesize novel renditions of them in different contexts. In this work, we present a new approach for "personalization" of text-to-image diffusion models. Given as input just a few images of a subject, we fine-tune a pretrained text-to-image model such that it learns to bind a unique identifier with that specific subject. Once the subject is embedded in the output domain of the model, the unique identifier can be used to synthesize novel photorealistic images of the subject contextualized in different scenes. By leveraging the semantic prior embedded in the model with a new autogenous class-specific prior preservation loss, our technique enables synthesizing the subject in diverse scenes, poses, views and lighting conditions that do not appear in the reference images. We apply our technique to several previously-unassailable tasks, including subject recontextualization, text-guided view synthesis, and artistic rendering, all while preserving the subject's key features. We also provide a new dataset and evaluation protocol for this new task of subject-driven generation. Project page: https://dreambooth.github.io/},
13 pubstate = {preprint}
14}
15
16@article{owidco2andothergreenhousegasemissions,
17 author = {Hannah Ritchie and Max Roser and Pablo Rosado},
18 title = {CO₂ and Greenhouse Gas Emissions},
19 journal = {Our World in Data},
20 year = {2020},
21 note = {https://ourworldindata.org/co2-and-other-greenhouse-gas-emissions}
22}
23
24@article{lacoste2019quantifying,
25 title={Quantifying the Carbon Emissions of Machine Learning},
26 author={Lacoste, Alexandre and Luccioni, Alexandra and Schmidt, Victor and Dandres, Thomas},
27 journal={arXiv preprint arXiv:1910.09700},
28 year={2019}
29}
30