{ "cells": [ { "cell_type": "markdown", "id": "42762e28-ddc2-4053-a9a2-983f8beada3c", "metadata": {}, "source": [ "### Imports" ] }, { "cell_type": "code", "execution_count": 39, "id": "3458eb91-216b-498a-ada8-79100c79b300", "metadata": {}, "outputs": [], "source": [ "from Garage import Augmenter\n", "from PIL import Image" ] }, { "cell_type": "markdown", "id": "5027a8d2-4579-42c3-aadb-6fc5fbaf1fd0", "metadata": {}, "source": [ "### Model initialization" ] }, { "cell_type": "code", "execution_count": 51, "id": "edbc4812-15a0-4cbf-85fb-6dc64e2031a6", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "6f7a1aae97c942d98174bb105841eac9", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Loading checkpoint shards: 0%| | 0/4 [00:00 by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. Both the diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .\n", "An error occurred while trying to fetch /home/jovyan/ddorin/generative_augmentation/Garage/Garage/models/checkpoints/ppt-v2-1/realisticVisionV60B1_v51VAE: Error no file named diffusion_pytorch_model.safetensors found in directory /home/jovyan/ddorin/generative_augmentation/Garage/Garage/models/checkpoints/ppt-v2-1/realisticVisionV60B1_v51VAE.\n", "Defaulting to unsafe serialization. Pass `allow_pickle=False` to raise an error instead.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "08/13 01:44:22 - mmengine - \u001b[4m\u001b[97mINFO\u001b[0m - Successfully add external embeddings: P_ctxt, P_shape, P_obj.\n", "08/13 01:44:22 - mmengine - \u001b[4m\u001b[97mINFO\u001b[0m - Successfully add trainable external embeddings: P_ctxt, P_shape, P_obj\n" ] } ], "source": [ "model = Augmenter()" ] }, { "cell_type": "markdown", "id": "04e9f042-9197-4884-afb7-da1dcea7ab49", "metadata": {}, "source": [ "### Examples of working" ] }, { "cell_type": "code", "execution_count": 52, "id": "5a7e688d", "metadata": {}, "outputs": [], "source": [ "image = Image.open(\"examples/image.jpg\")\n", "cat_mask = Image.open(\"examples/cat_mask.jpg\")" ] }, { "cell_type": "code", "execution_count": 5, "id": "76f8bfa9-5385-40a0-b8bb-3d5406475e76", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "3276373b9c144f449e683bb2514e790d", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/50 [00:00" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "new_image, (prompt, new_object) = model(image=image,\n", " mask=cat_mask,\n", " current_object=\"cat\",\n", " new_objects_list=None,\n", " ddim_steps=50,\n", " guidance_scale=5,\n", " seed=3,\n", " return_prompt=True)\n", "\n", "print(f'New object: {new_object}, prompt: {prompt}\\n')\n", "new_image.show()" ] }, { "cell_type": "code", "execution_count": 6, "id": "8d7c96ce", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "317594fc88ee4ba693d8884dc2899c4a", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/50 [00:00" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "new_image, (prompt, new_object) = model(image=image,\n", " mask=cat_mask,\n", " current_object=\"cat\",\n", " new_objects_list=[\"train\", \"tree\", \"bear\", \"rabbit\", \"wolf\", \"car\"],\n", " ddim_steps=50,\n", " guidance_scale=5,\n", " seed=41,\n", " return_prompt=True)\n", "\n", "print(f'New object: {new_object}, prompt: {prompt}\\n')\n", "new_image.show()" ] } ], "metadata": { "kernelspec": { "display_name": "ddorin", "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.14" } }, "nbformat": 4, "nbformat_minor": 5 }