Skip to content

Instantly share code, notes, and snippets.

@alighamdan
Last active December 19, 2022 15:11
Show Gist options
  • Save alighamdan/c558caec0fb0b5bec249d9957e4d425e to your computer and use it in GitHub Desktop.
Save alighamdan/c558caec0fb0b5bec249d9957e4d425e to your computer and use it in GitHub Desktop.
dreamlike ai.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyPQcVegkFSw2OjW+dVRKAnv",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU",
"gpuClass": "standard",
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"2883c9efe63649fcb79c9c6fc2267c5a": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "HBoxModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "HBoxView",
"box_style": "",
"children": [
"IPY_MODEL_955defacbf4a4b97b705eb2fb554ca49",
"IPY_MODEL_f6038e47a23a40b38d32ac11ad8ade62",
"IPY_MODEL_b7fea42d89f849c0a7f5515a42dc0b7e"
],
"layout": "IPY_MODEL_e5e2a1346eea48f8b9b6004fe50d1107"
}
},
"955defacbf4a4b97b705eb2fb554ca49": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "HTMLModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "HTMLView",
"description": "",
"description_tooltip": null,
"layout": "IPY_MODEL_681cc67ed93345fa983a402e53565f86",
"placeholder": "​",
"style": "IPY_MODEL_eab1cad0f71b4d3880cef236a3a98f2e",
"value": "Fetching 13 files: 100%"
}
},
"f6038e47a23a40b38d32ac11ad8ade62": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "FloatProgressModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "ProgressView",
"bar_style": "success",
"description": "",
"description_tooltip": null,
"layout": "IPY_MODEL_1ff77b1998ba4f1fb58c553f55bd2934",
"max": 13,
"min": 0,
"orientation": "horizontal",
"style": "IPY_MODEL_1d0b55d4b64244b2aa16e7fad19653e4",
"value": 13
}
},
"b7fea42d89f849c0a7f5515a42dc0b7e": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "HTMLModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "HTMLView",
"description": "",
"description_tooltip": null,
"layout": "IPY_MODEL_87dc3a3f2b7b4aa68a2f875995f129ba",
"placeholder": "​",
"style": "IPY_MODEL_56c86d5f0e304c2ca49fe285e8bb7c90",
"value": " 13/13 [00:00<00:00, 509.63it/s]"
}
},
"e5e2a1346eea48f8b9b6004fe50d1107": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"681cc67ed93345fa983a402e53565f86": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"eab1cad0f71b4d3880cef236a3a98f2e": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"model_module_version": "1.5.0",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "DescriptionStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "StyleView",
"description_width": ""
}
},
"1ff77b1998ba4f1fb58c553f55bd2934": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"1d0b55d4b64244b2aa16e7fad19653e4": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"model_module_version": "1.5.0",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "ProgressStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "StyleView",
"bar_color": null,
"description_width": ""
}
},
"87dc3a3f2b7b4aa68a2f875995f129ba": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"56c86d5f0e304c2ca49fe285e8bb7c90": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"model_module_version": "1.5.0",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "DescriptionStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "StyleView",
"description_width": ""
}
}
}
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/alighamdan/c558caec0fb0b5bec249d9957e4d425e/dreamlike-ai.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"source": [
"# INSTALL DEPENDENCIES "
],
"metadata": {
"id": "Aek_U9pkmfYJ"
}
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "pGQaxtC2lxL7",
"outputId": "da89fdef-bbc3-4b1f-d543-5ff3ee9777f9"
},
"outputs": [],
"source": [
"! pip install gradio torch diffusers\n",
"! pip install transformers\n",
"! pip install accelerate"
]
},
{
"cell_type": "code",
"source": [
"from diffusers import StableDiffusionPipeline\n",
"import torch\n",
"from IPython.display import Image\n",
"\n",
"model_id = \"dreamlike-art/dreamlike-diffusion-1.0\" # can be: dreamlike-art/dreamlike-photoreal-1.0\n",
"pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to('cuda')"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 156,
"referenced_widgets": [
"2883c9efe63649fcb79c9c6fc2267c5a",
"955defacbf4a4b97b705eb2fb554ca49",
"f6038e47a23a40b38d32ac11ad8ade62",
"b7fea42d89f849c0a7f5515a42dc0b7e",
"e5e2a1346eea48f8b9b6004fe50d1107",
"681cc67ed93345fa983a402e53565f86",
"eab1cad0f71b4d3880cef236a3a98f2e",
"1ff77b1998ba4f1fb58c553f55bd2934",
"1d0b55d4b64244b2aa16e7fad19653e4",
"87dc3a3f2b7b4aa68a2f875995f129ba",
"56c86d5f0e304c2ca49fe285e8bb7c90"
]
},
"id": "bDyqpfFkm-o-",
"outputId": "8aec03d6-b0af-49a3-e372-56658e0b3e66"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"prompt = \"cute young girl with orange hair and red eyes with small smile\"\n",
"negative_prompt = \"\"\n",
"steps = 30\n",
"scale = 7.5\n",
"width = 768\n",
"height = 768\n",
"seed = 0\n",
"result = pipe(\n",
" prompt, \n",
" negative_prompt = negative_prompt, \n",
" num_inference_steps=steps, \n",
" guidance_scale = scale, \n",
" width=width, \n",
" height=height, \n",
" generator = torch.Generator('cuda').manual_seed(seed) if seed != 0 else None\n",
" )\n",
"\n",
"result.images[0].save(\"./result.jpg\")\n",
"\n",
"Image('./result.jpg')"
],
"metadata": {
"id": "gAL0Y3PRnoF_"
},
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment