2022-01-24 11:47:29 +00:00
|
|
|
|
{
|
|
|
|
|
"cells": [
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"# Samila Demo"
|
|
|
|
|
]
|
|
|
|
|
},
|
2024-09-01 19:28:06 +00:00
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
2024-11-18 17:04:29 +00:00
|
|
|
|
"### Version : 1.4\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"---"
|
|
|
|
|
]
|
|
|
|
|
},
|
2022-01-24 11:47:29 +00:00
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"import sys\n",
|
|
|
|
|
"try:\n",
|
|
|
|
|
" import google.colab\n",
|
|
|
|
|
" !{sys.executable} -m pip -q -q install samila\n",
|
|
|
|
|
"except:\n",
|
|
|
|
|
" pass"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"import matplotlib.pyplot as plt\n",
|
|
|
|
|
"import random\n",
|
|
|
|
|
"import math\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"from samila import GenerativeImage, Projection, Marker, GenerateMode"
|
2022-01-24 11:47:29 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"## Magic\n",
|
2024-09-03 15:22:43 +00:00
|
|
|
|
"If we create a `GenerativeImage` instance with no input parameters, we will get a plot generated from two random equations."
|
2022-01-24 11:47:29 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"execution_count": null,
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"metadata": {},
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"outputs": [],
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"source": [
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"g1 = GenerativeImage()\n",
|
|
|
|
|
"g1.generate()\n",
|
|
|
|
|
"g1.plot()\n",
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"plt.show()"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"## Assigning Functions\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"By defining `f1` and `f2`, we can control the general shape of the plot."
|
2022-01-24 11:47:29 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"execution_count": null,
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"metadata": {},
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"outputs": [],
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"source": [
|
|
|
|
|
"def f1(x, y):\n",
|
|
|
|
|
" result = random.uniform(-1,1) * x**2 - math.sin(y**2) + abs(y-x)\n",
|
|
|
|
|
" return result\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"def f2(x, y):\n",
|
|
|
|
|
" result = random.uniform(-1,1) * y**3 - math.cos(x**2) + 2*x\n",
|
|
|
|
|
" return result\n",
|
|
|
|
|
"\n",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"g2 = GenerativeImage(f1, f2)\n",
|
|
|
|
|
"g2.generate()\n",
|
|
|
|
|
"g2.plot()\n",
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"plt.show()"
|
|
|
|
|
]
|
|
|
|
|
},
|
2024-09-01 19:28:06 +00:00
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## Generation Mode"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"We have the option to select from various generation modes.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"ℹ️ The avaliable modes are `F1_VS_F2`, `F2_VS_F1`, `F1_VS_INDEX`, `F2_VS_INDEX`, `INDEX_VS_F1`, `INDEX_VS_F2`, `F1_VS_X1`, `F1_VS_X2`, `F2_VS_X1`, `F2_VS_X2`, `X1_VS_F1`, `X1_VS_F2`, `X2_VS_F1` and `X2_VS_F2`"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"ℹ️ Default mode is `F1_VS_F2`"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"g2 = GenerativeImage(f1, f2)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"for mode in list(GenerateMode):\n",
|
|
|
|
|
" print(mode)\n",
|
|
|
|
|
" g2.generate(mode=mode)\n",
|
|
|
|
|
" g2.plot()\n",
|
|
|
|
|
" plt.show()\n",
|
|
|
|
|
" plt.close()"
|
|
|
|
|
]
|
|
|
|
|
},
|
2022-01-24 11:47:29 +00:00
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## Projection\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"We can use the `projection` attribute to define the coordinate system to transform our functions.\n",
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"ℹ️ The avaliable projections are `RECTILINEAR`, `POLAR`, `AITOFF`, `HAMMER`, `LAMBERT`, `MOLLWEIDE` and `RANDOM`"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"ℹ️ Default projection is `RECTILINEAR`"
|
2022-01-24 11:47:29 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"execution_count": null,
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"metadata": {},
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"outputs": [],
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"source": [
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"g2 = GenerativeImage(f1, f2)\n",
|
|
|
|
|
"g2.generate()\n",
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"for projection in list(Projection):\n",
|
|
|
|
|
" print(projection)\n",
|
|
|
|
|
" g2.plot(projection=projection)\n",
|
2022-01-24 11:47:29 +00:00
|
|
|
|
" plt.show()\n",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
" plt.close()"
|
2022-01-24 11:47:29 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
2022-11-05 22:16:28 +00:00
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## Marker\n",
|
|
|
|
|
"We can use the `marker` attribute to change the plotting marker.\n",
|
|
|
|
|
"\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"ℹ️ The available markers are `POINT`, `PIXEL`, `CIRCLE`, `TRIANGLE_DOWN`, `TRIANGLE_UP`, `TRIANGLE_LEFT`, `TRIANGLE_RIGHT`, `TRI_DOWN`, `TRI_UP`, `TRI_LEFT`, `TRI_RIGHT`, `OCTAGON`, `SQUARE`, `PENTAGON`, `PLUS`, `PLUS_FILLED`, `STAR`, `HEXAGON_VERTICAL`, `HEXAGON_HORIZONTAL`, `X`, `X_FILLED`, `DIAMOND`, `DIAMON_THIN`, `VLINE`, `HLINE` and `RANDOM`"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"ℹ️ Default marker is `POINT`"
|
2022-11-05 22:16:28 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"g2 = GenerativeImage(f1, f2)\n",
|
|
|
|
|
"g2.generate()\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"for m in list(Marker):\n",
|
|
|
|
|
" print(m)\n",
|
|
|
|
|
" g2.plot(marker=m, spot_size=100)\n",
|
|
|
|
|
" plt.show()\n",
|
|
|
|
|
" plt.close()"
|
|
|
|
|
]
|
|
|
|
|
},
|
2023-03-26 15:00:40 +00:00
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"## Rotation\n",
|
2023-03-26 15:00:40 +00:00
|
|
|
|
"You can even rotate your art by using `rotation` parameter. Enter your desired rotation for the image in degrees and you will have it.\n",
|
|
|
|
|
"\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"ℹ️ Default rotation is `0`"
|
2023-03-26 15:00:40 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"g = GenerativeImage(f1, f2)\n",
|
|
|
|
|
"g.generate()\n",
|
|
|
|
|
"g.plot(rotation=45)"
|
|
|
|
|
]
|
|
|
|
|
},
|
2022-01-24 11:47:29 +00:00
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## Range\n",
|
|
|
|
|
"\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"Control the range over which the input values span."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"ℹ️ Default range is $(-\\pi, \\pi)$"
|
2022-01-24 11:47:29 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"execution_count": null,
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"metadata": {},
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"outputs": [],
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"source": [
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"g2 = GenerativeImage(f1, f2)\n",
|
|
|
|
|
"g2.generate(start=-1.5*math.pi, step=0.007, stop=0)\n",
|
|
|
|
|
"g2.plot(projection=Projection.POLAR)\n",
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"plt.show()"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## Color\n",
|
|
|
|
|
"\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"We can assign colors for both the background as well as the line.\n"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"ℹ️ Default color is `black`\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"ℹ️ Default background-color is `white`"
|
2022-01-24 11:47:29 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"execution_count": null,
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"metadata": {},
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"outputs": [],
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"source": [
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"g2 = GenerativeImage(f1, f2)\n",
|
|
|
|
|
"g2.generate()\n",
|
|
|
|
|
"g2.plot(color=\"maroon\", bgcolor=\"antiquewhite\", projection=Projection.POLAR)\n",
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"plt.show()"
|
|
|
|
|
]
|
|
|
|
|
},
|
2022-04-20 08:57:16 +00:00
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"ℹ️ Supported colors are available in `VALID_COLORS` list\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"ℹ️ `color` and `bgcolor` parameters supported formats:\n",
|
2022-04-20 08:57:16 +00:00
|
|
|
|
"\n",
|
2022-05-17 13:24:04 +00:00
|
|
|
|
" 1. Color name (example: `color=\"yellow\"`)\n",
|
|
|
|
|
" 2. RGB/RGBA (example: `color=(0.1,0.1,0.1)`, `color=(0.1,0.1,0.1,0.1)`)\n",
|
|
|
|
|
" 3. Hex (example: `color=\"#eeefff\"`)\n",
|
|
|
|
|
" 4. Random (example: `color=\"random\"`)\n",
|
2022-05-19 21:49:51 +00:00
|
|
|
|
" 5. Complement (example: `color=\"complement\", bgcolor=\"blue\"`)\n",
|
|
|
|
|
" 6. Transparent (example: `bgcolor=\"transparent\"`)\n",
|
2022-09-09 12:27:14 +00:00
|
|
|
|
" 7. List (example: `color=[\"black\", \"#fffeef\",...]`)\n",
|
2022-05-19 21:49:51 +00:00
|
|
|
|
"\n",
|
2022-09-09 12:27:14 +00:00
|
|
|
|
"⚠️ **Transparent** mode is only available for background\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"⚠️ **List** mode is only available for color\n",
|
|
|
|
|
"\n",
|
2022-09-14 16:20:39 +00:00
|
|
|
|
"⚠️ In **List** mode, the length of this list must be equal to the lengths of data1 and data2"
|
2022-09-09 12:27:14 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"### Point Color\n",
|
|
|
|
|
"\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"You can make your custom color map and use it in Samila."
|
2022-09-09 12:27:14 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"colorarray = [\n",
|
|
|
|
|
" [0.7, 0.2, 0.2, 1],\n",
|
|
|
|
|
" [0.6, 0.3, 0.2, 1],\n",
|
|
|
|
|
" \"black\",\n",
|
|
|
|
|
" [0.4, 0.4, 0.3, 1],\n",
|
|
|
|
|
" [0.3, 0.4, 0.4, 1],\n",
|
|
|
|
|
" \"#ff2561\"]\n",
|
|
|
|
|
"g2.generate()\n",
|
|
|
|
|
"g2.plot(cmap=colorarray, color=g2.data2, projection=Projection.POLAR)\n",
|
|
|
|
|
"plt.show()"
|
2022-04-20 08:57:16 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
2022-01-24 11:47:29 +00:00
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## Spot Size\n",
|
|
|
|
|
"\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"We can also change the size of the plot marker."
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"ℹ️ Default spot-size is `0.01`"
|
2022-01-24 11:47:29 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"execution_count": null,
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"metadata": {},
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"outputs": [],
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"source": [
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"g2 = GenerativeImage(f1, f2)\n",
|
|
|
|
|
"g2.generate()\n",
|
|
|
|
|
"g2.plot(color=\"yellow\", bgcolor=\"darkslategray\", spot_size=0.25)\n",
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"plt.show()"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## Random Seeds\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"If we do not pass in a seed when calling `generate`, a random seed will be created for us.\n",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"Passing this seed into `generate` will guarantee plot reproducibility."
|
2022-01-24 11:47:29 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"execution_count": null,
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"metadata": {},
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"outputs": [],
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"source": [
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"seed = g2.seed\n",
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"print(seed)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"execution_count": null,
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"metadata": {},
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"outputs": [],
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"source": [
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"g2 = GenerativeImage(f1, f2)\n",
|
|
|
|
|
"g2.generate(seed)\n",
|
|
|
|
|
"g2.plot(color=\"yellow\", bgcolor=\"darkslategray\", spot_size=0.05)\n",
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"plt.show()"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## Saving Images\n",
|
|
|
|
|
"\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"Save generated images.\n",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"Use the `depth` attribute to increase the resolution."
|
2022-01-24 11:47:29 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"execution_count": null,
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"metadata": {},
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"outputs": [],
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"source": [
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"g2.save_image(file_adr=\"test.png\")"
|
2022-01-24 11:47:29 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"execution_count": null,
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"metadata": {},
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"outputs": [],
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"source": [
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"g2.save_image(file_adr=\"test_high_res.png\", depth=3)"
|
2022-01-24 11:47:29 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## Saving Data\n",
|
|
|
|
|
"\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"Save generated image data.\n",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"It can then be loaded into a `GenerativeImage` instance."
|
2022-03-16 10:29:35 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"g2.save_data(file_adr=\"data.json\")"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"g2 = GenerativeImage(data=open('data.json', 'r'))\n",
|
|
|
|
|
"g2.plot()"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"## Saving Config\n",
|
|
|
|
|
"\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"Save generated image config. It contains string formats of functions which is also human readable.\n",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"\n",
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"It can then be loaded into a `GenerativeImage` instance."
|
2022-01-24 11:47:29 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"execution_count": null,
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"metadata": {},
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"outputs": [],
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"source": [
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"g1.save_config(file_adr=\"config.json\")"
|
2022-01-24 11:47:29 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"g1 = GenerativeImage(config=open('config.json', 'r'))\n",
|
|
|
|
|
"g1.generate()\n",
|
|
|
|
|
"g1.plot()"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
2022-01-24 11:47:29 +00:00
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"## NFT.storage"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"Upload generated image directly to [NFT.storage](https://nft.storage)."
|
2022-01-24 11:47:29 +00:00
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"source": [
|
|
|
|
|
"g1.nft_storage(api_key=\"YOUR_API_KEY\")"
|
|
|
|
|
]
|
2022-11-22 09:31:58 +00:00
|
|
|
|
},
|
2023-03-26 21:39:43 +00:00
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"g1.nft_storage(api_key=\"YOUR_API_KEY\", timeout=5000)"
|
|
|
|
|
]
|
|
|
|
|
},
|
2022-11-22 09:31:58 +00:00
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
|
|
|
|
"You can also upload your config/data to nft storage as follows:"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"g1.nft_storage(api_key=\"YOUR_API_KEY\", upload_config=True)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"g1.nft_storage(api_key=\"YOUR_API_KEY\", upload_data=True)"
|
|
|
|
|
]
|
2023-03-26 21:39:43 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"source": [
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"⚠️ This method is deprecated and may be removed in future releases\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"ℹ️ Default timeout is `3000` seconds\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"ℹ️ Default gateway is `IPFS_IO`"
|
2023-03-26 21:39:43 +00:00
|
|
|
|
]
|
2022-01-24 11:47:29 +00:00
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"metadata": {
|
|
|
|
|
"kernelspec": {
|
2023-03-26 21:39:43 +00:00
|
|
|
|
"display_name": "Python 3",
|
2022-03-16 10:29:35 +00:00
|
|
|
|
"language": "python",
|
|
|
|
|
"name": "python3"
|
2022-01-24 11:47:29 +00:00
|
|
|
|
},
|
|
|
|
|
"language_info": {
|
|
|
|
|
"codemirror_mode": {
|
|
|
|
|
"name": "ipython",
|
|
|
|
|
"version": 3
|
|
|
|
|
},
|
|
|
|
|
"file_extension": ".py",
|
|
|
|
|
"mimetype": "text/x-python",
|
|
|
|
|
"name": "python",
|
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
|
"pygments_lexer": "ipython3",
|
2023-03-26 21:39:43 +00:00
|
|
|
|
"version": "3.5.2"
|
2022-09-14 16:20:39 +00:00
|
|
|
|
},
|
|
|
|
|
"toc": {
|
|
|
|
|
"base_numbering": 1,
|
|
|
|
|
"nav_menu": {},
|
|
|
|
|
"number_sections": false,
|
|
|
|
|
"sideBar": true,
|
|
|
|
|
"skip_h1_title": true,
|
|
|
|
|
"title_cell": "Samila Demo",
|
|
|
|
|
"title_sidebar": "Samila Demo",
|
|
|
|
|
"toc_cell": false,
|
|
|
|
|
"toc_position": {
|
|
|
|
|
"height": "382px",
|
|
|
|
|
"left": "10px",
|
|
|
|
|
"top": "10px",
|
|
|
|
|
"width": "256px"
|
|
|
|
|
},
|
|
|
|
|
"toc_section_display": false,
|
2024-09-01 19:28:06 +00:00
|
|
|
|
"toc_window_display": false
|
2022-09-09 12:27:14 +00:00
|
|
|
|
},
|
|
|
|
|
"vscode": {
|
|
|
|
|
"interpreter": {
|
2022-11-22 09:31:58 +00:00
|
|
|
|
"hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a"
|
2022-09-09 12:27:14 +00:00
|
|
|
|
}
|
2022-03-16 10:29:35 +00:00
|
|
|
|
}
|
2022-01-24 11:47:29 +00:00
|
|
|
|
},
|
|
|
|
|
"nbformat": 4,
|
|
|
|
|
"nbformat_minor": 4
|
2022-09-09 12:27:14 +00:00
|
|
|
|
}
|