Last active
August 25, 2022 01:44
-
-
Save nazo6/c834ed83f02b04bd119b89a507df3cc9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "5532b32c-2cb8-4ad7-8dff-bae6b577cc01", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"!pip install --upgrade diffusers transformers scipy\n", | |
"!pip install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cu113" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "70fedaef-b47d-436c-b9ba-459ad6427012", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from diffusers import StableDiffusionPipeline\n", | |
"\n", | |
"YOUR_TOKEN = \"<token>\"\n", | |
"model_id = \"CompVis/stable-diffusion-v1-4\"\n", | |
"pipe = StableDiffusionPipeline.from_pretrained(model_id, use_auth_token=YOUR_TOKEN)\n", | |
"def dummy(images, **kwargs): return images, False \n", | |
"pipe.safety_checker = dummy\n", | |
"pipe.to(\"cuda\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "f364760b-d404-4765-ae26-c800e0313524", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"text = \"<prompt>\"\n", | |
"image = pipe(text, guidance_scale=10)[\"sample\"][0]\n", | |
"display(image)\n" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3 (ipykernel)", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.10.6" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment