This coding session is based on this notebook. If you do not have a Myriad account, you can use this notebook on Google Colab instead.
To setup Myriad and run your jobs just follow the following steps.
- You might not be connected by UCL network to which you need to conect to the UCL VPN for your OS:
-
Log in using the command line
ssh ucaXXXX@myriad.rc.ucl.ac.uk, whereucaXXXXis your UCL username. -
Once you have logged into Myriad, clone this repo using
git clone https://github.com/dlcv-journal-club/TextToImageModels, andcdinto the~/PATH_TO_REPO/TextToImageModels/dreamboothdirectory. -
Create a conda env which contains
pipand then set it upconda create -n dreambooth pip- Run
source conda_setup.shto setup the conda env.
-
(Optional) If you have your own images that you want to finetune with, delete all existing images in the
data/zwxdirectory. Then in another window, upload each of your photos usingscp YOUR_PHOTO.png ucaXXXX@myriad.rc.ucl.ac.uk:~/PATH_TO_REPO/dreambooth/data/zwx. -
(Optional) Switch back to your Myriad ssh session. If your subject is anything other than a dog, you will need to change all instances of the word "dog" in the
concepts_list.jsonfile. For example, if your subject is the Empire State Building, you may want to change "dog" to "tower", or if your subject is a specific person, you may want to change it to "person". You can edit this file usingvim concepts_list.json. -
The
inference.pyfile contains a prompt that will be used to generate our final images. Alter this file usingvim inference.py. Change thepromptvariable on line 16 to something fun, but make sure to keep the words "photo of zwx CLASS_NAME" at the start of the prompt. By default, CLASS_NAME will be "dog". -
Edit
finetuning.qsub.shandinference.qsub.shand review the contents:- Make sure the output directory under
#$ -o ~/FOO/exists. - Make sure it
cds to the correct location of thedreamboothdirectory - The--save_sample_promptoption should be changed if the input images are not of a dog, as in previous steps. Eg.--save_sample_prompt="photo of zwx tower"
- Make sure the output directory under
-
Queue your finetuning job using
qsub finetuning.qsub.sh. This will only need to be run once, unless you change your input images. Wait for it to finish. -
Queue your inference job using
qsub inference.qsub.sh. You can override the hard-coded prompt withMYPROMPT="photo of zwx dog, cartoon style" qsub -v MYPROMPT inference.qsub.sh. (Note that you can't pass a variable containing a comma to-vbecause it uses commas as the variable separator, hence the above workaround.) -
Wait for the job to complete; once it's done, you should see your images in the
imgsdirectory. You can rerun the previous step with a new prompt if you want.