Close this search box.

Generate AI image locally on MacBook M1 Pro in 5 minutes

Table of Contents

1. Introduction

In era of growing, like mushrooms in warm rainy day, subscription based online platforms that offers you image generation for little fee I decided to make quick round for making simple image without involving any expensive hardware. Just MacBook and internet connection. Let’s start.

2. Package installation

2.1. Install anaconda

To make it simple I used anaconda package manager. Below commands to install required dependencies.

					curl -O

I accepted default settings, entering everything.

2.2. Install pyTorch and tranformers

					conda install pytorch::pytorch torchvision torchaudio -c pytorch
conda install -c conda-forge diffusers
conda install -c huggingface transformers

3. Run script and get image

I decided to cherry pick ‘stable-diffusion-v1-5′ model. Then quick script that use prompt “sheep with big teeth in open jaws looking with big eyes

					cat <<EOF >
from diffusers import DiffusionPipeline

pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
pipe ="mps")

# uncomment below for mac with with less than 64 GB of RAM

prompt = "sheep with big teeth in open jaws looking with big eyes"
image = pipe(prompt).images[0]"test.png")

Now run script to get image:

					conda run python

4. Display image

Use any image browser to display image. Here is my result

Follow me on LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *

Share the Post:

Enjoy Free Useful Amazing Content

Related Posts