AI Images
---
Overview
- Images on websites
- AI in the Cloud
- AI Locally
- Stable Diffusion
- Questions
---
Images on websites
----
## Why images on websites
- Visual appeal
- Communication - a picture / thousands words
- Branding and identity
- Search Engine Optimization (SEO)
----
### Important aspects with images
- Copyright and Licensing
- Quality and Resolution
- Alt Text and Accessibility
- Image Size and Load Time
- Context and Relevance
- Cultural Sensitivity and Diversity
- Originality and Creativity -> SEO
----
### Issues with images
- Images found on the internet > Copyright claims
- Royalty-free images & originality
- AI Images > trained on images > Copyright infringement?
- AI generated Images > no manual labor > No Copyright?
- AI Images: Diminishing supply of original work
---
AI in the cloud
text-to-image models
----
DALL-E
- DALL·E, DALL·E 2., and DALL·E 3
- (WALL-E + Salvador Dalí)
- OpenAI (DALL·E 3 via ChatGPT-4)
----
### DALL-E via ChatGPT-4
> a photo realistic image of unwanted mail
----
### DALL-E via ChatGPT-4
> a photo realistic image of unwanted mail in landscape format
----
----
### stable-diffusion-turbo
> a photo realistic image of unwanted mail
----
----
### Leonardo AI
> a photo realistic image of unwanted mail
----
----
### Midjourney
> a photo realistic image of unwanted mail
----
----
### Generating Images in the Cloud
- Free services
- limited
- Paid services
- What happens with your data?
---
AI Locally
----
### AI Locally
- AI Software locally
- Photoshop
- Stable Diffusion
----
### Stable Diffusion
Checkpoint: stable-diffusion-v-1-4-original
> a photo realistic image of unwanted mail
----
### Stable Diffusion
Checkpoint: Cyberrealistic v4.1
> a photo realistic image of unwanted mail
----
### Stable Diffusion
Checkpoint: PicX_real
> a photo realistic image of unwanted mail
---
Installing Stable Diffusion
----
### Clone Stable Diffusion WebUI
```bash
$ git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
$ sudo apt install python3.10-venv
$ alias python=python3
$ python -m venv venv
$ sudo apt install libtcmalloc-minimal4
$ ./webui.sh
```
----
### Download Checkpoint
- huggingface: stable-diffusion-v-1-4-original
> The Stable-Diffusion-v-1-4 checkpoint was initialized
> with the weights of the Stable-Diffusion-v-1-2 checkpoint
> and subsequently fine-tuned on 225k steps
> at resolution 512x512 on "laion-aesthetics v2 5+"
> and 10% dropping of the text-conditioning
> to improve classifier-free guidance sampling.
----
### Improve performance
- NVidia CUDA (Compute Unified Device Architecture)
- parallel computing platform
- allows software developers to use a GPU for general-purpose processing
- proprietary and closed-source!
----
```bash
$ sudo ubuntu-drivers devices
```
```txt
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd000025A0sv00001028sd00000A61bc03sc02i00
vendor : NVIDIA Corporation
model : GA107M [GeForce RTX 3050 Ti Mobile]
driver : nvidia-driver-535-server-open - distro non-free
driver : nvidia-driver-525 - distro non-free
driver : nvidia-driver-470 - distro non-free
driver : nvidia-driver-535 - distro non-free recommended
driver : nvidia-driver-535-server - distro non-free
driver : nvidia-driver-535-open - distro non-free
driver : nvidia-driver-525-open - distro non-free
driver : nvidia-driver-525-server - distro non-free
driver : nvidia-driver-470-server - distro non-free
driver : xserver-xorg-video-nouveau - distro free builtin
```
----
```bash
$ sudo apt install nvidia-driver-535
$ sudo nvidia-smi
```
```txt
Tue Jan 2 10:48:47 2024
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.129.03 Driver Version: 535.129.03 CUDA Version: 12.2 |
|-----------------------------------------+----------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+======================+======================|
| 0 NVIDIA GeForce RTX 3050 ... Off | 00000000:01:00.0 Off | N/A |
| N/A 50C P0 N/A / 40W | 8MiB / 4096MiB | 0% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
+---------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=======================================================================================|
| 0 N/A N/A 2950 G /usr/lib/xorg/Xorg 4MiB |
+---------------------------------------------------------------------------------------+
```
----
#### Result
- Laptop does not "suspend" anymore....
----
#### First Results
----
#### more First Results
----
#### more First Results
---
Using Stable Diffusion
----
### Stable Diffusion checkpoint
- Large datasets used to train Model
- Models: civitai.com/models
- CyberRealistic
- PicX_real
----
### Prompt / Negative Prompt 1/2
- Use English
- Use keywords (not sentences)
- Use: Subject + verb + object + adjectives (beautiful)
- Order is important! First words most important.
- or change keyword weight (keyword:x.y) -> x.y = 1.33
----
### Prompt / Negative Prompt 1/2
- Specify:
- environment (indoor, outdoors, park)
- lighting (soft, ambient)
- tools or materials (pencil, photo)
- color scheme (dark, vibrant, dynamic lighting)
- camera (wide angle, close up)
- photography (polaroid, etc)
- art style
- art inspiration -> list of artists
----
### Prompt resources
- Extension: prompt generator
- check other images
- lexica.art - images
- prompthero.com
- stablediffusion.fr/prompts
- openart.ai
- openart.ai/promptbook !!!
----
### Parameters
- Sampling method (see Settings tab) -> de-noising
- Sampling Steps (depends on Sampling Method)
- Size 512x512 (most are trained on that)
- Batch count (how many times) -> serial processing
- Batch size (how many images) -> parallel, needs more GPU!
----
### Sampling method
- Ordinary differential equations (ODE) solvers
- Euler – simplest
- Heun – more accurate, slower
- LMS (Linear multi-step method)
- Ancestral samplers - every step different outcome
- Euler a
- DPM2 a
- DPM++ 2S a
----
### Classifier Free Guidance
- CFG = (how strict to follow prompt)
- 2-6 = creative
- 7-10 = creative/guided
- 10-15 = detailed clear prompt
- 16-20 = very detailed prompt
- more than 20 mostly unusable
----
### Seed
- initial random noise, -1 = random
- re-use seed = very similar image
source: stable-diffusion-art.com/samplers
----
### Other
- Restore face
- Tiling
- Hires
- in URL ?__theme=dark
- presets: style.csv
- AUTOMATIC1111: A Beginner’s Guide
- 5 methods to generate consistent face with Stable Diffusion
----
### Other tabs
- img2img
- PNG info - Get prompt info
- Extensions
----
#### Better Results
After changing the Checkpoint (model), Sampling Method and parameters:
----
#### Better Results
---
Using Stable Diffusion via API
----
### Stable Diffusion via API
in webui-user.sh
> export COMMANDLINE_ARGS="--skip-torch-cuda-test --medvram --api"
----
### Stable Diffusion via API
http://127.0.0.1:7860/docs
---
Questions?
----
## Photo Credits
- https://pixabay.com/photos/notebook-paper-pages-open-731212/
- https://unsplash.com/photos/landmark-poster-lot-QNc9tTNHRyI
- https://unsplash.com/photos/white-clouds-and-blue-sky-during-daytime-A9_IsUtjHm4
- https://unsplash.com/photos/a-robot-made-out-of-legos-sitting-on-a-table-jMDtJtFs8EQ
- https://unsplash.com/photos/three-drinking-glasses-Y1ge0B9_oGE
- https://unsplash.com/photos/mona-lisa-painting-0WQOCx1g8hw
- https://unsplash.com/photos/a-laptop-computer-sitting-on-top-of-a-wooden-desk-b25Eso94UH0
- https://unsplash.com/photos/white-and-blue-tablet-computer-keyboard-VFiQvZPlm2k
- https://unsplash.com/photos/a-group-of-electronic-devices-yJVpnfqu8GY
- https://unsplash.com/photos/person-holding-click-pen-FwF_fKj5tBo
- https://unsplash.com/photos/macro-photography-of-black-circuit-board-FO7JIlwjOtU
- https://unsplash.com/photos/question-mark-neon-signage-8xAA0f9yQnE