Skip to content

Commit

Permalink
Add some changes suggested on #325
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanHCenalmor committed Dec 17, 2024
1 parent 240a6b6 commit 6a9409b
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions Colab_notebooks/U-Net_3D_ZeroCostDL4Mic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "q4wM9Sr0Dbbf",
"cellView": "form"
"cellView": "form",
"id": "q4wM9Sr0Dbbf"
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -246,8 +246,8 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "fq21zJVFNASx",
"cellView": "form"
"cellView": "form",
"id": "fq21zJVFNASx"
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -698,6 +698,11 @@
" eps = 1e-6\n",
" y_true_f = K.flatten(y_true)\n",
" y_pred_f = K.flatten(y_pred)\n",
"\n",
" # Cast both to float 32 to avoid issues\n",
" y_true_f = K.cast(y_true_f, tf.float32)\n",
" y_true_f = K.cast(y_true_f, tf.float32)\n",
" \n",
" intersection = K.sum(y_true_f*y_pred_f)\n",
"\n",
" return (2.*intersection)/(K.sum(y_true_f*y_true_f)+K.sum(y_pred_f*y_pred_f)+eps)\n",
Expand Down Expand Up @@ -873,6 +878,7 @@
" save_weights_only=True)\n",
"\n",
" sample_batch, __ = val_generator.__getitem__(random.randint(0, len(val_generator)))\n",
"\n",
" sample_img = SampleImageCallback(self.model,\n",
" sample_batch,\n",
" model_path)\n",
Expand Down Expand Up @@ -1457,8 +1463,8 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ewpNJ_I0Mv47",
"cellView": "form"
"cellView": "form",
"id": "ewpNJ_I0Mv47"
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -1920,9 +1926,9 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "iwNmp1PUzRDQ",
"scrolled": true,
"cellView": "form"
"scrolled": true
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -1973,8 +1979,8 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "eAJzMwPA6tlH",
"cellView": "form"
"cellView": "form",
"id": "eAJzMwPA6tlH"
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -2031,8 +2037,8 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "vMzSP50kMv5p",
"cellView": "form"
"cellView": "form",
"id": "vMzSP50kMv5p"
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -2195,6 +2201,12 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "_XkpLksQQ-Cd"
},
"outputs": [],
"source": [
"\n",
"#@markdown ##Calculate Intersection over Union and best threshold\n",
Expand Down Expand Up @@ -2261,13 +2273,7 @@
"#Make a pdf summary of the QC results\n",
"\n",
"qc_pdf_export()"
],
"metadata": {
"cellView": "form",
"id": "_XkpLksQQ-Cd"
},
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "markdown",
Expand All @@ -2292,8 +2298,8 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ZY_Y0Y4t8bL3",
"cellView": "form"
"cellView": "form",
"id": "ZY_Y0Y4t8bL3"
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -3090,4 +3096,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}

0 comments on commit 6a9409b

Please sign in to comment.