{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "8b2458c4-c461-4ddc-af94-fcd837357da4", "metadata": {}, "outputs": [], "source": [ "from diffusers import PixArtAlphaPipeline\n", "import torch\n", "from diffusers import Transformer2DModel" ] }, { "cell_type": "code", "execution_count": null, "id": "81a5bc0f-682b-4ff9-92e9-43b68b3df8fc", "metadata": {}, "outputs": [], "source": [ "# for comparison\n", "\n", "orig_pipe = pipe = PixArtAlphaPipeline.from_pretrained(\"PixArt-alpha/PixArt-XL-2-512x512\", torch_dtype=torch.float16)\n", "orig_pipe = orig_pipe.to(\"cuda\")" ] }, { "cell_type": "code", "execution_count": null, "id": "efc07821-5479-4ca3-a2c6-114ac484fd1e", "metadata": {}, "outputs": [], "source": [ "transformer = Transformer2DModel.from_pretrained(\"/workspace/PixArt-alpha/output/diffusers_trained/transformer\", torch_dtype=torch.float16)\n", "pipe = PixArtAlphaPipeline.from_pretrained(\"PixArt-alpha/PixArt-XL-2-512x512\", torch_dtype=torch.float16, transformer=transformer)\n", "pipe = pipe.to(\"cuda\")" ] }, { "cell_type": "code", "execution_count": 22, "id": "57da873b-2c13-463b-b558-ee69522ccefc", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "d69c7683773c4c25914764800ec1ef4f", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/20 [00:00" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "prompt = \"A green pokemon on white background\"\n", "image = pipe(prompt=prompt).images[0]\n", "image" ] } ], "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.12" } }, "nbformat": 4, "nbformat_minor": 5 }