lecture 05
simple terminal commands
+
stable diffusion on your macbook
+
finally not mnist: train a POKEMON πŸ‘Ύ GAN
SeAts APp SEAtS ApP SEaTS APP
🧘
as usual, an AI-related fun project to wake us up
could be the most fun apps we've run so far
new AI models are coming up on a weekly basis,
on github or hugging face, etc.
some are quite open-source to play with!
this lecture is to show you an example of how to explore newly released models
spoiler:
~= the workflow of using others' github projects
after today's lecture:
-- cool hackers in the making
-- no longer to wait on server: stable diffusion on your laptop
-- pokemon GAN yay!
App here (big up)
It is based on this repo, check it out!
always check system requirement for every proj
Models (aka scaffold and weights) are not included on the git repo ,
- it is too large
- you have to be aware of the terms and conditions before using one
adventure/hacker mode:
download and convert stable diffusion model using coremltools
how to convert the stable diffusion model from pytorch to coreml model?
just like we did for caffe model, we'd use some python scripts with coremltools
good news is that apple has prepared the sd converter script!!!
off-the-record mode
hacker mode on πŸ₯·
some useful simple terminal commands
let's connect to the MATRIX by opening the terminal window
CLI
(command line interface)
vs.
GUI
(Graphic user interface)
pwd
(very simple, check which folder we are at now)
directory ~= folder
ls
(very simple, list the contents of current folder)
cd PATH_TO_A_FOLDER
(very simple, change current working folder, like the first-person game character moves into another level)
mkdir YourAwesomeNewFolderName
(very simple, make a new folder within current working folder)
little task: create a folder called "watermelon" on your desktop
steps:
use "pwd" to check where we are at
use "ls" to check what do we have here
use "cd folder_path" to go to where we want to work at
use "mkdir folder_name" to make a new folder
πŸŽ‰
steps here
just three more commands
conda create -n YourAwesomeEnvName
(create fresh new enviroment (only if you have anaconda) )
-n is a "flag", followed by an input,
think of it like an argument label in swift
git clone github_repo_url
(download a repo from github)
pip install packageName
example: pip install torch
(download packages in an environment)
(this cmd has other variations/flags which we'll meet shortly )
no hard memorisation, i still have to google many of them nowadays,
"they exist"
is all you need to know!
most cmd names are informative
hacker python routine
- create new environment (these cmds will become muscle memory)
- download the codes from github
- use pip to install requirements/dependencies/packages
- run the python file
running into hugging face error?
bugs ARE frustrating...
BUT
90% of them are solvable (from my humble experience)
think about this,
when the authors upload their repo,
- it is quite confident to say that this project can run successfully on their machine πŸ˜…
- but why it goes wrong on my machine? 😑
- because my machine (hardward and software) has some difference than theirs πŸ₯΅
- system requirements and packages dependencies are the most likely source of i-just-want-to-play-with-a-git-proj bugsπŸ›
debug tip: trace the error,
what file is causing the error?
and what project does that file belong to ?
original steps here
hugging face: the treasure place (i'm still learning!)
let's set up our hugging face account!
generate a token on hugging face and add the token
re-run the converter file
πŸŽ‰
Pokemon GAN
pokemon p1 - prepare environment routine
- create new environment (these cmds will become muscle memory)
- download the codes
- install requirements/dependencies/packages
pokemon p1 - prepare environment - with anaconda and spyder
- in anaconda, create new environment
- install spyder if you like
- download the codes and unzip
- open spyder, go to the codes' folder
- pip install -r requirements.txt
pokemon part 1 - prepare environment - terminal
- conda create -n YourAwesomeEnvName python=3.9 -y
- conda activate YourAwesomeEnvName
- cd YourFolderForThisLecture
- git clone https://github.com/XiaowanYi/PokeGAN.git
- cd PokeGAN
- pip install -r requirements.txt
this github repo comes with already trained models aka model with weights (recall the three life stages of ML models?)
we can run test.py to play with the trained model woohoo!
run this:
python test.py
what if we use a fun AI to convert the generated image to a 3D model???
following slides are for
downloading dataset of pokemon sprites
and training the GAN on your machine,
for a hustle-free process and use google's gpu,
go to this slide
pokemon part 2 - prepare dataset
- create new environment (these cmds will become muscle memory)
- use pip to install requirements/dependencies/packages
- run the python file
dataset here
drag png files (ignore subfolders) from
sprites-master/sprites/pokemon (the dataset downloaded)
to PokeGAN-master/data/ (codes downloaded)
we can run main.py to start training but it might be slow (feel free to try it our)
or google colab comes to rescue
new series episode 4 Devi Parikh computational creativity full-on
summary today
- command line hacks πŸ–²
- stable diffusion converter and mac App πŸ₯°
- Pokemon GAN trainπŸ“€
- Pokemon GAN play
have a lovely break!