Hannes Kuchelmeister
commited on
Commit
•
9d1e8db
1
Parent(s):
8d4f085
add example images to notebook
Browse files- notebooks/3.0-hfk-model-performance-visualisation.ipynb +48 -25
- notebooks/img/+0.000_I04136_X020_Y022_Z5283.jpg +0 -0
- notebooks/img/+0.007_I04138_X020_Y022_Z5351.jpg +0 -0
- notebooks/img/+0.014_I04139_X020_Y022_Z5419.jpg +0 -0
- notebooks/img/+0.021_I04140_X020_Y022_Z5488.jpg +0 -0
- notebooks/img/+0.027_I04137_X020_Y022_Z5556.jpg +0 -0
- notebooks/img/+0.034_I04134_X020_Y022_Z5625.jpg +0 -0
- notebooks/img/+0.041_I04132_X020_Y022_Z5693.jpg +0 -0
- notebooks/img/-0.006_I04135_X020_Y022_Z5214.jpg +0 -0
- notebooks/img/-0.014_I04133_X020_Y022_Z5146.jpg +0 -0
- notebooks/img/-0.021_I04131_X020_Y022_Z5078.jpg +0 -0
notebooks/3.0-hfk-model-performance-visualisation.ipynb
CHANGED
@@ -807,14 +807,11 @@
|
|
807 |
"metadata": {},
|
808 |
"outputs": [
|
809 |
{
|
810 |
-
"
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
"execution_count": 5,
|
816 |
-
"metadata": {},
|
817 |
-
"output_type": "execute_result"
|
818 |
},
|
819 |
{
|
820 |
"data": {
|
@@ -832,11 +829,16 @@
|
|
832 |
"source": [
|
833 |
"import numpy as np\n",
|
834 |
"import matplotlib.pyplot as plt\n",
|
|
|
835 |
"\n",
|
836 |
"plt.scatter(ys, preds, s=1)\n",
|
837 |
"plt.plot([-0.03, 0.03],[-0.03,0.03])\n",
|
838 |
"\n",
|
839 |
-
"
|
|
|
|
|
|
|
|
|
840 |
]
|
841 |
},
|
842 |
{
|
@@ -887,7 +889,7 @@
|
|
887 |
"output_type": "stream",
|
888 |
"text": [
|
889 |
"Type: trichuris\n",
|
890 |
-
"MAE: 0.
|
891 |
]
|
892 |
},
|
893 |
{
|
@@ -919,7 +921,7 @@
|
|
919 |
"output_type": "stream",
|
920 |
"text": [
|
921 |
"Type: ascaris\n",
|
922 |
-
"MAE: 0.
|
923 |
]
|
924 |
},
|
925 |
{
|
@@ -951,7 +953,7 @@
|
|
951 |
"output_type": "stream",
|
952 |
"text": [
|
953 |
"Type: schistosoma\n",
|
954 |
-
"MAE: 0.
|
955 |
]
|
956 |
},
|
957 |
{
|
@@ -983,7 +985,7 @@
|
|
983 |
"output_type": "stream",
|
984 |
"text": [
|
985 |
"Type: hookworm\n",
|
986 |
-
"MAE: 0.
|
987 |
]
|
988 |
},
|
989 |
{
|
@@ -1027,7 +1029,12 @@
|
|
1027 |
" ys.append(y.numpy())\n",
|
1028 |
" \n",
|
1029 |
" print(f\"Type: {type}\")\n",
|
1030 |
-
"
|
|
|
|
|
|
|
|
|
|
|
1031 |
" plt.scatter(ys, preds, s=1)\n",
|
1032 |
" plt.plot([-0.03, 0.03],[-0.03,0.03])\n",
|
1033 |
"\n",
|
@@ -1054,19 +1061,21 @@
|
|
1054 |
},
|
1055 |
{
|
1056 |
"cell_type": "code",
|
1057 |
-
"execution_count":
|
1058 |
"metadata": {},
|
1059 |
"outputs": [
|
1060 |
{
|
1061 |
-
"
|
1062 |
-
"
|
1063 |
-
"
|
1064 |
-
|
1065 |
-
"\
|
1066 |
-
"
|
1067 |
-
"
|
1068 |
-
"
|
1069 |
-
"
|
|
|
|
|
1070 |
]
|
1071 |
}
|
1072 |
],
|
@@ -1077,8 +1086,22 @@
|
|
1077 |
"\n",
|
1078 |
"tile_size = 150\n",
|
1079 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1080 |
"#img = Image.open(\"img/0.0137_I03524_X007_Y019_Z5634.jpg\") \n",
|
1081 |
-
"img = Image.open(
|
1082 |
"img_grey = ImageOps.grayscale(img)\n",
|
1083 |
"\n",
|
1084 |
"img_crop = img.crop([0, 0, tile_size*int(img.width/tile_size), tile_size*int(img.height/tile_size)])\n",
|
|
|
807 |
"metadata": {},
|
808 |
"outputs": [
|
809 |
{
|
810 |
+
"name": "stdout",
|
811 |
+
"output_type": "stream",
|
812 |
+
"text": [
|
813 |
+
"MAE: 0.0060480572283267975\n"
|
814 |
+
]
|
|
|
|
|
|
|
815 |
},
|
816 |
{
|
817 |
"data": {
|
|
|
829 |
"source": [
|
830 |
"import numpy as np\n",
|
831 |
"import matplotlib.pyplot as plt\n",
|
832 |
+
"from torchmetrics import MeanAbsoluteError\n",
|
833 |
"\n",
|
834 |
"plt.scatter(ys, preds, s=1)\n",
|
835 |
"plt.plot([-0.03, 0.03],[-0.03,0.03])\n",
|
836 |
"\n",
|
837 |
+
"ys_arr = torch.tensor(np.array(ys).flatten())\n",
|
838 |
+
"preds_arr = torch.tensor(np.array(preds).flatten())\n",
|
839 |
+
"\n",
|
840 |
+
"mean_absolute_error = MeanAbsoluteError()\n",
|
841 |
+
"print(f\"MAE: {mean_absolute_error(preds_arr, ys_arr)}\")\n"
|
842 |
]
|
843 |
},
|
844 |
{
|
|
|
889 |
"output_type": "stream",
|
890 |
"text": [
|
891 |
"Type: trichuris\n",
|
892 |
+
"MAE: 0.006043851841241121\n"
|
893 |
]
|
894 |
},
|
895 |
{
|
|
|
921 |
"output_type": "stream",
|
922 |
"text": [
|
923 |
"Type: ascaris\n",
|
924 |
+
"MAE: 0.006212816573679447\n"
|
925 |
]
|
926 |
},
|
927 |
{
|
|
|
953 |
"output_type": "stream",
|
954 |
"text": [
|
955 |
"Type: schistosoma\n",
|
956 |
+
"MAE: 0.006195892579853535\n"
|
957 |
]
|
958 |
},
|
959 |
{
|
|
|
985 |
"output_type": "stream",
|
986 |
"text": [
|
987 |
"Type: hookworm\n",
|
988 |
+
"MAE: 0.005734680686146021\n"
|
989 |
]
|
990 |
},
|
991 |
{
|
|
|
1029 |
" ys.append(y.numpy())\n",
|
1030 |
" \n",
|
1031 |
" print(f\"Type: {type}\")\n",
|
1032 |
+
"\n",
|
1033 |
+
" ys_arr = torch.tensor(np.array(ys).flatten())\n",
|
1034 |
+
" preds_arr = torch.tensor(np.array(preds).flatten())\n",
|
1035 |
+
"\n",
|
1036 |
+
" mean_absolute_error = MeanAbsoluteError()\n",
|
1037 |
+
" print(f\"MAE: {mean_absolute_error(preds_arr, ys_arr)}\")\n",
|
1038 |
" plt.scatter(ys, preds, s=1)\n",
|
1039 |
" plt.plot([-0.03, 0.03],[-0.03,0.03])\n",
|
1040 |
"\n",
|
|
|
1061 |
},
|
1062 |
{
|
1063 |
"cell_type": "code",
|
1064 |
+
"execution_count": 9,
|
1065 |
"metadata": {},
|
1066 |
"outputs": [
|
1067 |
{
|
1068 |
+
"name": "stderr",
|
1069 |
+
"output_type": "stream",
|
1070 |
+
"text": [
|
1071 |
+
"Error: no \"view\" mailcap rules found for type \"image/png\"\n",
|
1072 |
+
"Error: no \"view\" mailcap rules found for type \"image/png\"\n",
|
1073 |
+
"Error when invoking the open external command: Error in response: Unable to parse response as JSON: \n",
|
1074 |
+
"Error when invoking the open external command: Error in response: Unable to parse response as JSON: \n",
|
1075 |
+
"Error: no \"view\" mailcap rules found for type \"image/png\"\n",
|
1076 |
+
"Error when invoking the open external command: Error in response: Unable to parse response as JSON: \n",
|
1077 |
+
"Error: no \"view\" mailcap rules found for type \"image/png\"\n",
|
1078 |
+
"Error when invoking the open external command: Error in response: Unable to parse response as JSON: \n"
|
1079 |
]
|
1080 |
}
|
1081 |
],
|
|
|
1086 |
"\n",
|
1087 |
"tile_size = 150\n",
|
1088 |
"\n",
|
1089 |
+
"root_file_folder = \"img/\"\n",
|
1090 |
+
"files = [\n",
|
1091 |
+
" \"-0.021_I04131_X020_Y022_Z5078.jpg\",\n",
|
1092 |
+
" \"-0.014_I04133_X020_Y022_Z5146.jpg\",\n",
|
1093 |
+
" \"-0.006_I04135_X020_Y022_Z5214.jpg\",\n",
|
1094 |
+
" \"+0.000_I04136_X020_Y022_Z5283.jpg\",\n",
|
1095 |
+
" \"+0.007_I04138_X020_Y022_Z5351.jpg\",\n",
|
1096 |
+
" \"+0.014_I04139_X020_Y022_Z5419.jpg\",\n",
|
1097 |
+
" \"+0.021_I04140_X020_Y022_Z5488.jpg\",\n",
|
1098 |
+
" \"+0.027_I04137_X020_Y022_Z5556.jpg\",\n",
|
1099 |
+
" \"+0.034_I04134_X020_Y022_Z5625.jpg\",\n",
|
1100 |
+
" \"+0.041_I04132_X020_Y022_Z5693.jpg\",\n",
|
1101 |
+
"]\n",
|
1102 |
+
"\n",
|
1103 |
"#img = Image.open(\"img/0.0137_I03524_X007_Y019_Z5634.jpg\") \n",
|
1104 |
+
"img = Image.open(os.path.join(root_file_folder, files[0])) \n",
|
1105 |
"img_grey = ImageOps.grayscale(img)\n",
|
1106 |
"\n",
|
1107 |
"img_crop = img.crop([0, 0, tile_size*int(img.width/tile_size), tile_size*int(img.height/tile_size)])\n",
|
notebooks/img/+0.000_I04136_X020_Y022_Z5283.jpg
ADDED
notebooks/img/+0.007_I04138_X020_Y022_Z5351.jpg
ADDED
notebooks/img/+0.014_I04139_X020_Y022_Z5419.jpg
ADDED
notebooks/img/+0.021_I04140_X020_Y022_Z5488.jpg
ADDED
notebooks/img/+0.027_I04137_X020_Y022_Z5556.jpg
ADDED
notebooks/img/+0.034_I04134_X020_Y022_Z5625.jpg
ADDED
notebooks/img/+0.041_I04132_X020_Y022_Z5693.jpg
ADDED
notebooks/img/-0.006_I04135_X020_Y022_Z5214.jpg
ADDED
notebooks/img/-0.014_I04133_X020_Y022_Z5146.jpg
ADDED
notebooks/img/-0.021_I04131_X020_Y022_Z5078.jpg
ADDED