# Exploiting Google Colab for free Generative AI
# ðŧðĻ
---
# ð
## Python
#### The Wizardry Behind the Scenes
Python is a great tool
- **Versatile**
- **Expressive**
- **Community-driven**
----
But from great responsibilities...
- Is it scripting?
- Is it OOP and packages?
- Is it just a messy bunch of stuff?
----
# âïļ
## How should we use it?
---
# ðŠð
## Jupyter
#### Your Spellbook for Coding Adventures
Making Python interactive
&
integrated with Markdown!
----
### Jupyter
Hub > Lab > Notebook
----

---
# ðŠâĻ
## Google's Jupyter
#### Where Wizards Code Their Spells
Google created its own branch of Jupyter.
It's called:
----

---
# ð
## Commanding Magic
#### Unleashing the Shell's Power
Both Colab and Jupyter support "bypassing python".
With a `!` in front of a code cell one can run in the underlying shell.
----
One can run `cat /proc/cpuinfo`.
Or for example `ls ~`.
Or even `curl www.google.com`.
---
# ððððð
## Let's go Hogwarts
#### Get yourself your Colab space
----
Start here!

----
Create your first notebook:

Call it `GDG GenAI by Elemento`!
----
Embrace the power of GPUs:

----
Select Nvidia T4:

and save!
----
# ðŠðŧ
## Let's start the ~~hacking~~ spellcasting!
----
# ðŪ
### Summoning Spells
#### Installing the Fooocus Enchantment
Invoke the powers of Fooocus with a simple Git spell.
Create a code line and type:
```bash
!sudo apt update && sudo apt install git
```
----
Clone the Fooocus git repository locally bypassing again python:
```bash
!git clone https://github.com/lllyasviel/Fooocus.git
```
----
Install a single python package manually:
```bash
!apt install python3.10-venv
```
----
Let's move to the Fooocus directory.
Using `%` you can ask Colab to change the `workdir`.
```bash
%cd Fooocus
```
As a confirmation you'll get:
```
/content/Fooocus
```
---
# ðĶ
## Kickstart Fooocus
#### Channeling Your Generative Magic
Let's set it up: it will take some time!
```
!python3 -m venv fooocus_env && source fooocus_env/bin/activate && pip install -r requirements_versions.txt
```
---
# ðŠķ
## Wingardium leviosa!
#### Make it fly
Launch Fooocus by typing:
```bash
!source fooocus_env/bin/activate && python entry_with_update.py
```
----
# âïļ
It will download ~7GB of AI models.
Take a coffee!
----
Fooocus can automatically use `gradio.io` to become reachable from the outer world.
The current runtime is only reachable on localhost:

----
Fooocus provides many options on where to publish the web interface:
1. no option: listens on localhost (127.0.0.1)
1. `--listen` listens on local LAN
2. `--share` opens a proxy on gradio.io
----
Stop and edit the command cell as follows and run it again:
```bash
!source fooocus_env/bin/activate && python entry_with_update.py --share
```
----
You'll find the URL to open your web UI in the output lines!

---
# ðĻ
## Illuminating Artistry
#### Channeling Your Generative Magic
----

---
# ð
## Conclusion
#### Soaring High on the Wings of AI Creativity
- Embrace the **free** potential of Google Colab!
- Hack it to the max: bypass python to get the real underlying power.
- Ride the currents of GPU power and scale your magic to new heights.
----
<img height="300px" src="https://hackmd.io/_uploads/BJo8-fM2p.png">
Looking for more power?
https://fooocus.elemento.cloud
{"title":"Unleashing the Power of Google Colab for Generative AI ðŧðĻ","description":"Dive into the magic of Python, from scripting to powerful packages.","contributors":"[{\"id\":\"4e2bc6f4-f901-4289-9d6d-1bdec59bd8c6\",\"add\":5528,\"del\":1677}]"}