Skip to content

Commit

Permalink
working but needs cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
lcipolina committed Sep 27, 2022
1 parent 8f9f5d6 commit 87d371c
Showing 1 changed file with 33 additions and 30 deletions.
63 changes: 33 additions & 30 deletions ML/GLIDE-inpaint-automatic_input.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -346,26 +346,12 @@
{
"cell_type": "markdown",
"source": [
"Mask drawing function"
"Upload mask"
],
"metadata": {
"id": "HwTKIk0OHyoz"
}
},
{
"cell_type": "code",
"source": [
"#uploaded = files.upload()\n",
"# Get the name of uploaded image:\n",
"#for key in uploaded.keys():\n",
"# mask = key\n"
],
"metadata": {
"id": "MVlmVkYBNzst"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
Expand All @@ -387,6 +373,10 @@
"import base64, os\n",
"import cv2\n",
"\n",
"'''\n",
"NOT SURE IF THIS IS NEEDED\n",
"'''\n",
"\n",
"#convert input image to np array\n",
"img = cv2.imread(uploaded_image)\n",
"image64 = base64.b64encode(open(uploaded_image, 'rb').read()) #encoding images as text, this is a trick to manipulate the image better.\n",
Expand Down Expand Up @@ -431,13 +421,27 @@
"outputs": []
},
{
"cell_type": "markdown",
"cell_type": "code",
"source": [
"Implement a form to set the values for the sampling parameters."
"# Source image we are inpainting\n",
"source_image_256 = read_image(uploaded_image, size=256)\n",
"source_image_64 = read_image(uploaded_image, size=64)\n",
"\n",
"\n",
"\n",
"# The mask should always be a boolean 64x64 mask, and then we\n",
"# can upsample it for the second stage.\n",
"source_mask_64 = read_mask('mask.png',64)\n",
"source_mask_256 = read_mask('mask.png',256)\n",
"\n",
"# Visualize the image we are inpainting\n",
"show_images(source_image_256 * source_mask_256)"
],
"metadata": {
"id": "SUeWB72h2XXU"
}
"id": "D6g4O0_ySzxo"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
Expand All @@ -448,6 +452,15 @@
"id": "c5p3aksvSWjI"
}
},
{
"cell_type": "markdown",
"source": [
"Implement a form to set the values for the sampling parameters."
],
"metadata": {
"id": "SUeWB72h2XXU"
}
},
{
"cell_type": "code",
"source": [
Expand All @@ -465,17 +478,7 @@
"upsample_temp = 0.997#@param {type: \"number\"}\n",
"#0.997\n",
"\n",
"# Source image we are inpainting\n",
"source_image_256 = read_image(uploaded_image, size=256)\n",
"source_image_64 = read_image(uploaded_image, size=64)\n",
"\n",
"# The mask should always be a boolean 64x64 mask, and then we\n",
"# can upsample it for the second stage.\n",
"source_mask_64 = read_mask('mask.png',64)\n",
"source_mask_256 = read_mask('mask.png',256)\n",
"\n",
"# Visualize the image we are inpainting\n",
"show_images(source_image_256 * source_mask_256)"
"\n"
],
"metadata": {
"id": "OqzvRGX42Ol4",
Expand Down

0 comments on commit 87d371c

Please sign in to comment.