From 1c6610b9987bfa38c2bc4aa1cb3c0ab14f37066d Mon Sep 17 00:00:00 2001 From: souravraha Date: Fri, 6 Jan 2023 11:22:15 +0000 Subject: [PATCH 01/11] load other numpy dtypes --- flash/core/data/utilities/loading.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/flash/core/data/utilities/loading.py b/flash/core/data/utilities/loading.py index 7522882f30..715ed1d513 100644 --- a/flash/core/data/utilities/loading.py +++ b/flash/core/data/utilities/loading.py @@ -68,7 +68,12 @@ def _load_image_from_image(file): def _load_image_from_numpy(file): - return Image.fromarray(np.load(file).astype("uint8")).convert("RGB") +try: + return Image.fromarray(arr.astype('uint8', casting='safe')).convert('RGB') +except TypeError as e: + import warnings + warnings.warn(str(e) + '. Converting to float instead.', RuntimeWarning) + return Image.fromarray(arr.astype(float, casting='safe')).convert('RGB') def _load_spectrogram_from_image(file): From 1d2a0f63c497cd97edbd075c11ef6c11cc32a795 Mon Sep 17 00:00:00 2001 From: souravraha Date: Fri, 6 Jan 2023 12:22:14 +0000 Subject: [PATCH 02/11] add tabs --- flash/core/data/utilities/loading.py | 12 ++++++------ train_annotations.json | 1 + train_annotations/image_1.xml | 1 + train_annotations/image_2.xml | 1 + train_annotations/image_3.xml | 1 + 5 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 train_annotations.json create mode 100644 train_annotations/image_1.xml create mode 100644 train_annotations/image_2.xml create mode 100644 train_annotations/image_3.xml diff --git a/flash/core/data/utilities/loading.py b/flash/core/data/utilities/loading.py index 715ed1d513..c106657392 100644 --- a/flash/core/data/utilities/loading.py +++ b/flash/core/data/utilities/loading.py @@ -68,12 +68,12 @@ def _load_image_from_image(file): def _load_image_from_numpy(file): -try: - return Image.fromarray(arr.astype('uint8', casting='safe')).convert('RGB') -except TypeError as e: - import warnings - warnings.warn(str(e) + '. Converting to float instead.', RuntimeWarning) - return Image.fromarray(arr.astype(float, casting='safe')).convert('RGB') + try: + return Image.fromarray(arr.astype('uint8', casting='safe')).convert('RGB') + except TypeError as e: + import warnings + warnings.warn(str(e) + '. Converting to float instead.', RuntimeWarning) + return Image.fromarray(arr.astype(float, casting='safe')).convert('RGB') def _load_spectrogram_from_image(file): diff --git a/train_annotations.json b/train_annotations.json new file mode 100644 index 0000000000..ca2c84ce90 --- /dev/null +++ b/train_annotations.json @@ -0,0 +1 @@ +{"annotations": [{"area": 50, "bbox": [10, 20, 5, 10], "num_keypoints": 2, "keypoints": [10, 15, 2, 20, 30, 2], "category_id": 1, "id": 1, "image_id": 1, "iscrowd": 0}, {"area": 100, "bbox": [20, 30, 10, 10], "num_keypoints": 2, "keypoints": [20, 30, 2, 30, 40, 2], "category_id": 2, "id": 2, "image_id": 2, "iscrowd": 0}, {"area": 125, "bbox": [10, 20, 5, 25], "num_keypoints": 2, "keypoints": [10, 15, 2, 20, 45, 2], "category_id": 1, "id": 3, "image_id": 3, "iscrowd": 0}], "categories": [{"id": 1, "name": "cat", "supercategory": "cat", "keypoints": ["left ear", "right ear"]}, {"id": 2, "name": "dog", "supercategory": "dog", "keypoints": ["left ear", "right ear"]}], "images": [{"file_name": "image_1.png", "height": 64, "width": 64, "id": 1}, {"file_name": "image_2.png", "height": 64, "width": 64, "id": 2}, {"file_name": "image_3.png", "height": 64, "width": 64, "id": 3}]} \ No newline at end of file diff --git a/train_annotations/image_1.xml b/train_annotations/image_1.xml new file mode 100644 index 0000000000..ae82d3b16d --- /dev/null +++ b/train_annotations/image_1.xml @@ -0,0 +1 @@ +image_1.pngimage_1.pngexample64643catUnspecified00010152030 \ No newline at end of file diff --git a/train_annotations/image_2.xml b/train_annotations/image_2.xml new file mode 100644 index 0000000000..c1f802a66e --- /dev/null +++ b/train_annotations/image_2.xml @@ -0,0 +1 @@ +image_2.pngimage_2.pngexample64643dogUnspecified00020303040 \ No newline at end of file diff --git a/train_annotations/image_3.xml b/train_annotations/image_3.xml new file mode 100644 index 0000000000..dc29042972 --- /dev/null +++ b/train_annotations/image_3.xml @@ -0,0 +1 @@ +image_3.pngimage_3.pngexample64643catUnspecified00010152045 \ No newline at end of file From d1455d932ee05109267ac8469c03ef0466616868 Mon Sep 17 00:00:00 2001 From: souravraha Date: Fri, 6 Jan 2023 12:30:38 +0000 Subject: [PATCH 03/11] ran tests --- mask_1.npy | Bin 0 -> 4224 bytes mask_2.npy | Bin 0 -> 4224 bytes mask_3.npy | Bin 0 -> 4224 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 mask_1.npy create mode 100644 mask_2.npy create mode 100644 mask_3.npy diff --git a/mask_1.npy b/mask_1.npy new file mode 100644 index 0000000000000000000000000000000000000000..8fe4e2d317ef1d37964d8cf7cd0b25252b9570ff GIT binary patch literal 4224 zcmbW)JC0>V76s7we;7r22~s&os0;?sULza~EL5TjVYC`l1vuS3ik>iQUuFP>Qkn0@ zjX1G?=e+-a^W8tc{l1nz%70$pfB5v{$Jei4UjO_1m#=SLUVr-K<8L3|{riVsKED5u z&;Rl6U!Oks{L|0xe*NI@&)2doON3% zbIozi*?p~ZYANNkbFG+nmoeKpbIdba>GO^?tvh3#HScY+-!*2p>sY*AXy0?clXO-)mQTBmAZA-PQpVOA30dc_6&+XGkZdB&j z*{G8veH7bI}XRKKp5{U&TOm zSEruSAv}7Wd$d0H9JkKe)n%Kucj z3w}N?@M+DhuM^Q*Cafz|Yo!DC?xWSKFp$hSPq>I2E^xeL2TOWy9pH6eACSjXaV6&gIn{vH(|btHG|Zcry`)KTpge%Q5N0Ria{s5rDg`o4~GMw@Ngf? z2UcCaU`3))4u0sr^ja%9OyJzky3s45+9r)ck=;#1!Xlj;b%a)Sg?7IxL#5rB@!7)F zHq-Gcb%VXqKHsuKYxdgosm#hQbTz0VE}_{NP#r#^)6?%|t!PhWyyn`Q8_6bObzk{J z=km)&M3GPOh=N%oZ$m1ZZ3Ojv47}q=oUzxGO>v7rK%~SXC=`xFqClh|5#|MQmlH9z zoANtsxa83P9WqDp$qxCoS%$TXNN_QT=V1KFLbb6)94Yi_GBd&wKD;#^0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Nfn+DH6=p@$Yc4OiT)lP+?9Qk9)6(8;{Nf3suRy>j$1BlmNwhjVG_rMWq_+ zMn3V;DUO=`l^oS4IjIALI@Fyr*8k%0A zA!!uKBQsQAA;DbgPuIdMBd|M0NQY>}lI83l|1iC4bPa=XMSs%A<|N|)oz_l*iSk!o zAfdZNZ?P*#FaM7bvQk9SahWtpjnO0g8?Q|BK zzy%}F=hr; z2n(2G{>xw&zCcU2TRY0A7HF7=ZUh~jTnR@E+DL9kZ`veTk(=SqVJX%QcX$Enf4Gh+Fuh#D8@;VDT=0oPH^k2Iqg;X$mf4`oDgB#oH5 znt3xKkfl#Yg_!^nMTD4P0ql<;Gxph9`%w9`o@%$A9g!q>j3Ii&Gh|6Qn1hDVfbKZ@ z3}_5a%q9{SLoFvJ^D{M>c!pH47=cY_<|O?h12pBJSRRB`y_L%_@-zq|HNB^an3MEc zy#VSqO{3A-uq9{|mjEO>L1`$2ZsstU(C9O7XH?OFK%RGLH61`QlbP$MpBwT-lQJUI zv}xxSWgEiW1vHKoQDl^ujv7s%JV+E7IjfjWU`rPS``g8m)F{wTb-Z}R&a~8MPr&(K zwowcfkUxIR8px#Gh+OhyEK7IwE64(Ve032Cck%6w62U`Eq|f|W{BLc$nh=4 z*;{SYm+udmn6z@kZ!Db>A!}P=;hy7yI?Wb-+Y^9j^ zLy}Y!8mq(~>InE$EzCtmzAIQDuvM8=;tsbW%@%4PTvUW-Uq1vP)U=RiUSqI0^~q3L zOmJr)Cni@;^APcRfi!SEPQ(<{6wK%OTZHJg#_xoK&aZ2^f-V#~+$pkh7EIu&&t)(L zzbXw4XJf<4K%DtL?Tx41AvIl;)2!BH zJhw4~O Date: Fri, 6 Jan 2023 12:33:15 +0000 Subject: [PATCH 04/11] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- flash/core/data/utilities/loading.py | 7 ++++--- train_annotations.json | 2 +- train_annotations/image_1.xml | 2 +- train_annotations/image_2.xml | 2 +- train_annotations/image_3.xml | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/flash/core/data/utilities/loading.py b/flash/core/data/utilities/loading.py index c106657392..41358cb7c2 100644 --- a/flash/core/data/utilities/loading.py +++ b/flash/core/data/utilities/loading.py @@ -69,11 +69,12 @@ def _load_image_from_image(file): def _load_image_from_numpy(file): try: - return Image.fromarray(arr.astype('uint8', casting='safe')).convert('RGB') + return Image.fromarray(arr.astype("uint8", casting="safe")).convert("RGB") except TypeError as e: import warnings - warnings.warn(str(e) + '. Converting to float instead.', RuntimeWarning) - return Image.fromarray(arr.astype(float, casting='safe')).convert('RGB') + + warnings.warn(str(e) + ". Converting to float instead.", RuntimeWarning) + return Image.fromarray(arr.astype(float, casting="safe")).convert("RGB") def _load_spectrogram_from_image(file): diff --git a/train_annotations.json b/train_annotations.json index ca2c84ce90..2e5f72bf0b 100644 --- a/train_annotations.json +++ b/train_annotations.json @@ -1 +1 @@ -{"annotations": [{"area": 50, "bbox": [10, 20, 5, 10], "num_keypoints": 2, "keypoints": [10, 15, 2, 20, 30, 2], "category_id": 1, "id": 1, "image_id": 1, "iscrowd": 0}, {"area": 100, "bbox": [20, 30, 10, 10], "num_keypoints": 2, "keypoints": [20, 30, 2, 30, 40, 2], "category_id": 2, "id": 2, "image_id": 2, "iscrowd": 0}, {"area": 125, "bbox": [10, 20, 5, 25], "num_keypoints": 2, "keypoints": [10, 15, 2, 20, 45, 2], "category_id": 1, "id": 3, "image_id": 3, "iscrowd": 0}], "categories": [{"id": 1, "name": "cat", "supercategory": "cat", "keypoints": ["left ear", "right ear"]}, {"id": 2, "name": "dog", "supercategory": "dog", "keypoints": ["left ear", "right ear"]}], "images": [{"file_name": "image_1.png", "height": 64, "width": 64, "id": 1}, {"file_name": "image_2.png", "height": 64, "width": 64, "id": 2}, {"file_name": "image_3.png", "height": 64, "width": 64, "id": 3}]} \ No newline at end of file +{"annotations": [{"area": 50, "bbox": [10, 20, 5, 10], "num_keypoints": 2, "keypoints": [10, 15, 2, 20, 30, 2], "category_id": 1, "id": 1, "image_id": 1, "iscrowd": 0}, {"area": 100, "bbox": [20, 30, 10, 10], "num_keypoints": 2, "keypoints": [20, 30, 2, 30, 40, 2], "category_id": 2, "id": 2, "image_id": 2, "iscrowd": 0}, {"area": 125, "bbox": [10, 20, 5, 25], "num_keypoints": 2, "keypoints": [10, 15, 2, 20, 45, 2], "category_id": 1, "id": 3, "image_id": 3, "iscrowd": 0}], "categories": [{"id": 1, "name": "cat", "supercategory": "cat", "keypoints": ["left ear", "right ear"]}, {"id": 2, "name": "dog", "supercategory": "dog", "keypoints": ["left ear", "right ear"]}], "images": [{"file_name": "image_1.png", "height": 64, "width": 64, "id": 1}, {"file_name": "image_2.png", "height": 64, "width": 64, "id": 2}, {"file_name": "image_3.png", "height": 64, "width": 64, "id": 3}]} diff --git a/train_annotations/image_1.xml b/train_annotations/image_1.xml index ae82d3b16d..6cfbcabd66 100644 --- a/train_annotations/image_1.xml +++ b/train_annotations/image_1.xml @@ -1 +1 @@ -image_1.pngimage_1.pngexample64643catUnspecified00010152030 \ No newline at end of file +image_1.pngimage_1.pngexample64643catUnspecified00010152030 diff --git a/train_annotations/image_2.xml b/train_annotations/image_2.xml index c1f802a66e..9e71bcccf2 100644 --- a/train_annotations/image_2.xml +++ b/train_annotations/image_2.xml @@ -1 +1 @@ -image_2.pngimage_2.pngexample64643dogUnspecified00020303040 \ No newline at end of file +image_2.pngimage_2.pngexample64643dogUnspecified00020303040 diff --git a/train_annotations/image_3.xml b/train_annotations/image_3.xml index dc29042972..bd941bbfb2 100644 --- a/train_annotations/image_3.xml +++ b/train_annotations/image_3.xml @@ -1 +1 @@ -image_3.pngimage_3.pngexample64643catUnspecified00010152045 \ No newline at end of file +image_3.pngimage_3.pngexample64643catUnspecified00010152045 From ff1e4683bc6f011ae5d5712256b2a739c7801ea4 Mon Sep 17 00:00:00 2001 From: souravraha Date: Fri, 6 Jan 2023 12:38:14 +0000 Subject: [PATCH 05/11] removedd arr --- flash/core/data/utilities/loading.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flash/core/data/utilities/loading.py b/flash/core/data/utilities/loading.py index c106657392..42e704b86f 100644 --- a/flash/core/data/utilities/loading.py +++ b/flash/core/data/utilities/loading.py @@ -69,11 +69,11 @@ def _load_image_from_image(file): def _load_image_from_numpy(file): try: - return Image.fromarray(arr.astype('uint8', casting='safe')).convert('RGB') + return Image.fromarray(np.load(file).astype('uint8', casting='safe')).convert('RGB') except TypeError as e: import warnings warnings.warn(str(e) + '. Converting to float instead.', RuntimeWarning) - return Image.fromarray(arr.astype(float, casting='safe')).convert('RGB') + return Image.fromarray(np.load(file).astype(float, casting='safe')).convert('RGB') def _load_spectrogram_from_image(file): From dc688fb6ade93dcef30e37d0f0386a517fedefe3 Mon Sep 17 00:00:00 2001 From: souravraha Date: Fri, 6 Jan 2023 12:45:51 +0000 Subject: [PATCH 06/11] ran tests --- mask_1.npy | Bin 4224 -> 0 bytes mask_2.npy | Bin 4224 -> 0 bytes mask_3.npy | Bin 4224 -> 0 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 mask_1.npy delete mode 100644 mask_2.npy delete mode 100644 mask_3.npy diff --git a/mask_1.npy b/mask_1.npy deleted file mode 100644 index 8fe4e2d317ef1d37964d8cf7cd0b25252b9570ff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4224 zcmbW)JC0>V76s7we;7r22~s&os0;?sULza~EL5TjVYC`l1vuS3ik>iQUuFP>Qkn0@ zjX1G?=e+-a^W8tc{l1nz%70$pfB5v{$Jei4UjO_1m#=SLUVr-K<8L3|{riVsKED5u z&;Rl6U!Oks{L|0xe*NI@&)2doON3% zbIozi*?p~ZYANNkbFG+nmoeKpbIdba>GO^?tvh3#HScY+-!*2p>sY*AXy0?clXO-)mQTBmAZA-PQpVOA30dc_6&+XGkZdB&j z*{G8veH7bI}XRKKp5{U&TOm zSEruSAv}7Wd$d0H9JkKe)n%Kucj z3w}N?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!}P=;hy7yI?Wb-+Y^9j^ zLy}Y!8mq(~>InE$EzCtmzAIQDuvM8=;tsbW%@%4PTvUW-Uq1vP)U=RiUSqI0^~q3L zOmJr)Cni@;^APcRfi!SEPQ(<{6wK%OTZHJg#_xoK&aZ2^f-V#~+$pkh7EIu&&t)(L zzbXw4XJf<4K%DtL?Tx41AvIl;)2!BH zJhw4~O Date: Fri, 6 Jan 2023 12:59:32 +0000 Subject: [PATCH 07/11] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- flash/core/data/utilities/loading.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/flash/core/data/utilities/loading.py b/flash/core/data/utilities/loading.py index 42e704b86f..eb58496ff7 100644 --- a/flash/core/data/utilities/loading.py +++ b/flash/core/data/utilities/loading.py @@ -69,11 +69,12 @@ def _load_image_from_image(file): def _load_image_from_numpy(file): try: - return Image.fromarray(np.load(file).astype('uint8', casting='safe')).convert('RGB') + return Image.fromarray(np.load(file).astype("uint8", casting="safe")).convert("RGB") except TypeError as e: import warnings - warnings.warn(str(e) + '. Converting to float instead.', RuntimeWarning) - return Image.fromarray(np.load(file).astype(float, casting='safe')).convert('RGB') + + warnings.warn(str(e) + ". Converting to float instead.", RuntimeWarning) + return Image.fromarray(np.load(file).astype(float, casting="safe")).convert("RGB") def _load_spectrogram_from_image(file): From 831279818db6970b91ecc247b5a7f906046ad3eb Mon Sep 17 00:00:00 2001 From: souravraha Date: Wed, 11 Jan 2023 16:12:49 +0000 Subject: [PATCH 08/11] deleted spurious files --- train_annotations.json | 1 - train_annotations/image_1.xml | 1 - train_annotations/image_2.xml | 1 - train_annotations/image_3.xml | 1 - 4 files changed, 4 deletions(-) delete mode 100644 train_annotations.json delete mode 100644 train_annotations/image_1.xml delete mode 100644 train_annotations/image_2.xml delete mode 100644 train_annotations/image_3.xml diff --git a/train_annotations.json b/train_annotations.json deleted file mode 100644 index 2e5f72bf0b..0000000000 --- a/train_annotations.json +++ /dev/null @@ -1 +0,0 @@ -{"annotations": [{"area": 50, "bbox": [10, 20, 5, 10], "num_keypoints": 2, "keypoints": [10, 15, 2, 20, 30, 2], "category_id": 1, "id": 1, "image_id": 1, "iscrowd": 0}, {"area": 100, "bbox": [20, 30, 10, 10], "num_keypoints": 2, "keypoints": [20, 30, 2, 30, 40, 2], "category_id": 2, "id": 2, "image_id": 2, "iscrowd": 0}, {"area": 125, "bbox": [10, 20, 5, 25], "num_keypoints": 2, "keypoints": [10, 15, 2, 20, 45, 2], "category_id": 1, "id": 3, "image_id": 3, "iscrowd": 0}], "categories": [{"id": 1, "name": "cat", "supercategory": "cat", "keypoints": ["left ear", "right ear"]}, {"id": 2, "name": "dog", "supercategory": "dog", "keypoints": ["left ear", "right ear"]}], "images": [{"file_name": "image_1.png", "height": 64, "width": 64, "id": 1}, {"file_name": "image_2.png", "height": 64, "width": 64, "id": 2}, {"file_name": "image_3.png", "height": 64, "width": 64, "id": 3}]} diff --git a/train_annotations/image_1.xml b/train_annotations/image_1.xml deleted file mode 100644 index 6cfbcabd66..0000000000 --- a/train_annotations/image_1.xml +++ /dev/null @@ -1 +0,0 @@ -image_1.pngimage_1.pngexample64643catUnspecified00010152030 diff --git a/train_annotations/image_2.xml b/train_annotations/image_2.xml deleted file mode 100644 index 9e71bcccf2..0000000000 --- a/train_annotations/image_2.xml +++ /dev/null @@ -1 +0,0 @@ -image_2.pngimage_2.pngexample64643dogUnspecified00020303040 diff --git a/train_annotations/image_3.xml b/train_annotations/image_3.xml deleted file mode 100644 index bd941bbfb2..0000000000 --- a/train_annotations/image_3.xml +++ /dev/null @@ -1 +0,0 @@ -image_3.pngimage_3.pngexample64643catUnspecified00010152045 From 1f7643b1f0e1167ed27ab5f2cc0136c2dc71acde Mon Sep 17 00:00:00 2001 From: souravraha Date: Fri, 27 Jan 2023 16:01:29 +0000 Subject: [PATCH 09/11] Scale pixel values before casting Signed-off-by: souravraha --- flash/core/data/utilities/loading.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/flash/core/data/utilities/loading.py b/flash/core/data/utilities/loading.py index 890ff1a16e..5fa638e2c9 100644 --- a/flash/core/data/utilities/loading.py +++ b/flash/core/data/utilities/loading.py @@ -73,13 +73,17 @@ def _load_image_from_image(file): def _load_image_from_numpy(file): - try: - return Image.fromarray(np.load(file).astype("uint8", casting="safe")).convert("RGB") - except TypeError as e: - import warnings - - warnings.warn(str(e) + ". Converting to float instead.", RuntimeWarning) - return Image.fromarray(np.load(file).astype(float, casting="safe")).convert("RGB") + arr = np.load(file) + # Max pixel value -> 255, min -> 0 + arr = 255 * (arr.max() - arr) / (arr.max() - arr.min()) + return Image.fromarray(arr.astype("uint8")).convert("RGB") + # try: + # return Image.fromarray(np.load(file).astype("uint8", casting="safe")).convert("RGB") + # except TypeError as e: + # import warnings + + # warnings.warn(str(e) + ". Converting to float instead.", RuntimeWarning) + # return Image.fromarray(np.load(file).astype(float, casting="safe")).convert("RGB") def _load_spectrogram_from_image(file): From e2fe64ab73b2dc59e925348379885ef5716bc1b9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 27 Jan 2023 16:02:46 +0000 Subject: [PATCH 10/11] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- flash/core/data/utilities/loading.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/flash/core/data/utilities/loading.py b/flash/core/data/utilities/loading.py index 5fa638e2c9..b0821324ae 100644 --- a/flash/core/data/utilities/loading.py +++ b/flash/core/data/utilities/loading.py @@ -73,17 +73,19 @@ def _load_image_from_image(file): def _load_image_from_numpy(file): - arr = np.load(file) - # Max pixel value -> 255, min -> 0 - arr = 255 * (arr.max() - arr) / (arr.max() - arr.min()) - return Image.fromarray(arr.astype("uint8")).convert("RGB") - # try: - # return Image.fromarray(np.load(file).astype("uint8", casting="safe")).convert("RGB") - # except TypeError as e: - # import warnings - - # warnings.warn(str(e) + ". Converting to float instead.", RuntimeWarning) - # return Image.fromarray(np.load(file).astype(float, casting="safe")).convert("RGB") + arr = np.load(file) + # Max pixel value -> 255, min -> 0 + arr = 255 * (arr.max() - arr) / (arr.max() - arr.min()) + return Image.fromarray(arr.astype("uint8")).convert("RGB") + + +# try: +# return Image.fromarray(np.load(file).astype("uint8", casting="safe")).convert("RGB") +# except TypeError as e: +# import warnings + +# warnings.warn(str(e) + ". Converting to float instead.", RuntimeWarning) +# return Image.fromarray(np.load(file).astype(float, casting="safe")).convert("RGB") def _load_spectrogram_from_image(file): From 619b2deee4576e0dff04044e666edd69069a50ad Mon Sep 17 00:00:00 2001 From: souravraha Date: Sat, 28 Jan 2023 12:49:31 +0530 Subject: [PATCH 11/11] Minor correction in formula --- flash/core/data/utilities/loading.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/flash/core/data/utilities/loading.py b/flash/core/data/utilities/loading.py index b0821324ae..e1653cf81a 100644 --- a/flash/core/data/utilities/loading.py +++ b/flash/core/data/utilities/loading.py @@ -74,18 +74,12 @@ def _load_image_from_image(file): def _load_image_from_numpy(file): arr = np.load(file) - # Max pixel value -> 255, min -> 0 - arr = 255 * (arr.max() - arr) / (arr.max() - arr.min()) - return Image.fromarray(arr.astype("uint8")).convert("RGB") - + if not (arr == arr.astype("uint8")).all(): + # Max pixel value -> 255, min -> 0 + low = arr.min() + arr = 255 * (arr - low) / (arr.max() - low) -# try: -# return Image.fromarray(np.load(file).astype("uint8", casting="safe")).convert("RGB") -# except TypeError as e: -# import warnings - -# warnings.warn(str(e) + ". Converting to float instead.", RuntimeWarning) -# return Image.fromarray(np.load(file).astype(float, casting="safe")).convert("RGB") + return Image.fromarray(arr.astype("uint8")).convert("RGB") def _load_spectrogram_from_image(file):