Run this model with HF Jobs
Run AiArtLab/simplevae on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/AiArtLab/simplevae. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/AiArtLab/simplevae on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use AiArtLab/simplevae with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use AiArtLab/simplevae with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("AiArtLab/simplevae", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse filesFiles changed (6)
- .gitattributes+2
- .ipynb_checkpoints/test-checkpoint.ipynbAdded+95
- create.ipynbAdded
- test.ipynbAdded+95
- vae/config.jsonAdded+48
- vae/diffusion_pytorch_model.safetensorsAdded+3
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines333435363732 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textgenerated.png filter=lfs diff=lfs merge=lfs -texttest.png filter=lfs diff=lfs merge=lfs -text
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "4f62bfd9-5396-48e2-aac7-bdf639cab345", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "The config attributes {'block_out_channels': [128, 256, 512, 768, 768], 'force_upcast': False} were passed to AsymmetricAutoencoderKL, but are not expected and will be ignored. Please verify your config.json configuration file.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "ok\n" ] } ], "source": [ "import torch\n", "\n", "from torchvision import transforms, utils\n", "\n", "import diffusers\n", "from diffusers import AsymmetricAutoencoderKL\n", "\n", "from diffusers.utils import load_image\n", "\n", "def crop_image_to_nearest_divisible_by_8(img):\n", " # Check if the image height and width are divisible by 8\n", " if img.shape[1] % 8 == 0 and img.shape[2] % 8 == 0:\n", " return img\n", " else:\n", " # Calculate the closest lower resolution divisible by 8\n", " new_height = img.shape[1] - (img.shape[1] % 8)\n", " new_width = img.shape[2] - (img.shape[2] % 8)\n", " \n", " # Use CenterCrop to crop the image\n", " transform = transforms.CenterCrop((new_height, new_width), interpolation=transforms.InterpolationMode.BILINEAR)\n", " img = transform(img).to(torch.float32).clamp(-1, 1)\n", " \n", " return img\n", " \n", "to_tensor = transforms.ToTensor()\n", "\n", "device = \"cuda\"\n", "dtype=torch.float16\n", "vae = AsymmetricAutoencoderKL.from_pretrained(\"vae\",torch_dtype=dtype).to(device).eval()\n", "\n", "image = load_image(\"generated.png\")\n", "\n", "image = crop_image_to_nearest_divisible_by_8(to_tensor(image)).unsqueeze(0).to(device,dtype=dtype)\n", "\n", "upscaled_image = vae(image).sample\n", "# Save the reconstructed image\n", "utils.save_image(upscaled_image, \"test.png\")\n", "print('ok')" ] }, { "cell_type": "code", "execution_count": null, "id": "7e3ad326-c410-44b6-a738-15b7f7e15075", "metadata": {}, "outputs": [], "source": [] } ], "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.11.6" } }, "nbformat": 4, "nbformat_minor": 5}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "4f62bfd9-5396-48e2-aac7-bdf639cab345", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "The config attributes {'block_out_channels': [128, 256, 512, 768, 768], 'force_upcast': False} were passed to AsymmetricAutoencoderKL, but are not expected and will be ignored. Please verify your config.json configuration file.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "ok\n" ] } ], "source": [ "import torch\n", "\n", "from torchvision import transforms, utils\n", "\n", "import diffusers\n", "from diffusers import AsymmetricAutoencoderKL\n", "\n", "from diffusers.utils import load_image\n", "\n", "def crop_image_to_nearest_divisible_by_8(img):\n", " # Check if the image height and width are divisible by 8\n", " if img.shape[1] % 8 == 0 and img.shape[2] % 8 == 0:\n", " return img\n", " else:\n", " # Calculate the closest lower resolution divisible by 8\n", " new_height = img.shape[1] - (img.shape[1] % 8)\n", " new_width = img.shape[2] - (img.shape[2] % 8)\n", " \n", " # Use CenterCrop to crop the image\n", " transform = transforms.CenterCrop((new_height, new_width), interpolation=transforms.InterpolationMode.BILINEAR)\n", " img = transform(img).to(torch.float32).clamp(-1, 1)\n", " \n", " return img\n", " \n", "to_tensor = transforms.ToTensor()\n", "\n", "device = \"cuda\"\n", "dtype=torch.float16\n", "vae = AsymmetricAutoencoderKL.from_pretrained(\"vae\",torch_dtype=dtype).to(device).eval()\n", "\n", "image = load_image(\"generated.png\")\n", "\n", "image = crop_image_to_nearest_divisible_by_8(to_tensor(image)).unsqueeze(0).to(device,dtype=dtype)\n", "\n", "upscaled_image = vae(image).sample\n", "# Save the reconstructed image\n", "utils.save_image(upscaled_image, \"test.png\")\n", "print('ok')" ] }, { "cell_type": "code", "execution_count": null, "id": "7e3ad326-c410-44b6-a738-15b7f7e15075", "metadata": {}, "outputs": [], "source": [] } ], "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.11.6" } }, "nbformat": 4, "nbformat_minor": 5}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748{ "_class_name": "AsymmetricAutoencoderKL", "_diffusers_version": "0.33.1", "_name_or_path": "simple_vae", "act_fn": "silu", "block_out_channels": [ 128, 256, 512, 768, 768 ], "down_block_out_channels": [ 128, 256, 512, 512 ], "down_block_types": [ "DownEncoderBlock2D", "DownEncoderBlock2D", "DownEncoderBlock2D", "DownEncoderBlock2D" ], "force_upcast": false, "in_channels": 3, "latent_channels": 16, "layers_per_down_block": 2, "layers_per_up_block": 2, "norm_num_groups": 32, "out_channels": 3, "sample_size": 1024, "scaling_factor": 1, "up_block_out_channels": [ 128, 256, 512, 768, 768 ], "up_block_types": [ "UpDecoderBlock2D", "UpDecoderBlock2D", "UpDecoderBlock2D", "UpDecoderBlock2D", "UpDecoderBlock2D" ]}123version https://git-lfs.github.com/spec/v1oid sha256:a09af5fe391d8095fd1937160c5990f1da40d3f83b4836f25ca43699c3729de9size 349017470.gitattributes+2
.ipynb_checkpoints/test-checkpoint.ipynbAdded+95
create.ipynbAdded
test.ipynbAdded+95
vae/config.jsonAdded+48
vae/diffusion_pytorch_model.safetensorsAdded+3