From e9add40d0985af7840be5725b9782edf76a66367 Mon Sep 17 00:00:00 2001 From: Laura Ootes Date: Wed, 31 Jul 2024 09:17:26 +0200 Subject: [PATCH 01/11] change example label name --- dianna/dashboard/pages/Time_series.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dianna/dashboard/pages/Time_series.py b/dianna/dashboard/pages/Time_series.py index ca3ad385..ea3a2b2e 100644 --- a/dianna/dashboard/pages/Time_series.py +++ b/dianna/dashboard/pages/Time_series.py @@ -20,21 +20,21 @@ st.sidebar.header('Input data') -load_example = st.sidebar.checkbox('Load example data', key='TS_example_check') +load_example_weather = st.sidebar.checkbox('Load weather example', key='TS_weather_example_check') ts_file = st.sidebar.file_uploader('Select input data', type='npy', - disabled=load_example) + disabled=load_example_weather) ts_model_file = st.sidebar.file_uploader('Select model', type='onnx', - disabled=load_example) + disabled=load_example_weather) ts_label_file = st.sidebar.file_uploader('Select labels', type='txt', - disabled=load_example) + disabled=load_example_weather) -if load_example: +if load_example_weather: ts_file = (data_directory / 'weather_data.npy') ts_model_file = (model_directory / 'season_prediction_model_temp_max_binary.onnx') From 6f968103b49424e884cf03d71bf9a6f966b1c9a3 Mon Sep 17 00:00:00 2001 From: Laura Ootes Date: Wed, 31 Jul 2024 09:40:10 +0200 Subject: [PATCH 02/11] add text explaining the weather example --- dianna/dashboard/pages/Time_series.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dianna/dashboard/pages/Time_series.py b/dianna/dashboard/pages/Time_series.py index ea3a2b2e..5a2c90fc 100644 --- a/dianna/dashboard/pages/Time_series.py +++ b/dianna/dashboard/pages/Time_series.py @@ -40,6 +40,15 @@ 'season_prediction_model_temp_max_binary.onnx') ts_label_file = (label_directory / 'weather_data_labels.txt') + st.markdown( + """This example is based on a binary classification task to predict which season it is, only cosidering summer and winter. + The input data is the [weather prediction dataset](https://zenodo.org/records/5071376). + This classification model uses time (days) as function of mean temperature to classify the whole time series is either + summer or winter. + In this example DIANNA is used to compute the relevance scores on top of the displayed timeseries. The days contributing + positively towards the classification decision are indicated in red and those who contribute negatively in blue. + """) + if not (ts_file and ts_model_file and ts_label_file): st.info('Add your input data in the left panel to continue') st.stop() From 9f90e3dd7bbdb0aef57d996d38f0bd2df854e1fe Mon Sep 17 00:00:00 2001 From: Laura Ootes Date: Wed, 31 Jul 2024 09:43:45 +0200 Subject: [PATCH 03/11] specify which example --- dianna/dashboard/pages/Text.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dianna/dashboard/pages/Text.py b/dianna/dashboard/pages/Text.py index a426437c..3a5ddb62 100644 --- a/dianna/dashboard/pages/Text.py +++ b/dianna/dashboard/pages/Text.py @@ -18,23 +18,23 @@ st.sidebar.header('Input data') -load_example = st.sidebar.checkbox('Load example data', +load_example_moviesentiment = st.sidebar.checkbox('Load movie sentiment example', key='Text_example_check') -text_input = st.sidebar.text_input('Input string', disabled=load_example) +text_input = st.sidebar.text_input('Input string', disabled=load_example_moviesentiment) if text_input: st.sidebar.write(text_input) text_model_file = st.sidebar.file_uploader('Select model', type='onnx', - disabled=load_example) + disabled=load_example_moviesentiment) text_label_file = st.sidebar.file_uploader('Select labels', type='txt', - disabled=load_example) + disabled=load_example_moviesentiment) -if load_example: +if load_example_moviesentiment: text_input = 'The movie started out great but the ending was dissappointing' text_model_file = model_directory / 'movie_review_model.onnx' text_label_file = label_directory / 'labels_text.txt' From 99f87e6e15a1678aa84f4ed6a502f01668004de3 Mon Sep 17 00:00:00 2001 From: Laura Ootes Date: Wed, 31 Jul 2024 09:54:26 +0200 Subject: [PATCH 04/11] modify text --- dianna/dashboard/pages/Time_series.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dianna/dashboard/pages/Time_series.py b/dianna/dashboard/pages/Time_series.py index 5a2c90fc..e5369c49 100644 --- a/dianna/dashboard/pages/Time_series.py +++ b/dianna/dashboard/pages/Time_series.py @@ -41,12 +41,12 @@ ts_label_file = (label_directory / 'weather_data_labels.txt') st.markdown( - """This example is based on a binary classification task to predict which season it is, only cosidering summer and winter. - The input data is the [weather prediction dataset](https://zenodo.org/records/5071376). - This classification model uses time (days) as function of mean temperature to classify the whole time series is either - summer or winter. - In this example DIANNA is used to compute the relevance scores on top of the displayed timeseries. The days contributing - positively towards the classification decision are indicated in red and those who contribute negatively in blue. + """This example demonstrates the use of DIANNA + on a pre-trained binary classification model for season prediction. + The input data is the + [weather prediction dataset](https://zenodo.org/records/5071376). + This classification model uses time (days) as function of mean temperature to predict if the whole time series is either summer or winter. + Using a chosen XAI method the relevance scores are displayed on top of the timeseries. The days contributing positively towards the classification decision are indicated in red and those who contribute negatively in blue. """) if not (ts_file and ts_model_file and ts_label_file): From b84a0a10df5f1febd3d0f6c4d8c8775544981751 Mon Sep 17 00:00:00 2001 From: Laura Ootes Date: Wed, 31 Jul 2024 09:54:40 +0200 Subject: [PATCH 05/11] add text explaoining the example --- dianna/dashboard/pages/Text.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dianna/dashboard/pages/Text.py b/dianna/dashboard/pages/Text.py index 3a5ddb62..95dbebda 100644 --- a/dianna/dashboard/pages/Text.py +++ b/dianna/dashboard/pages/Text.py @@ -39,6 +39,12 @@ text_model_file = model_directory / 'movie_review_model.onnx' text_label_file = label_directory / 'labels_text.txt' + st.markdown( + """ + This example demonstrates the use of DIANNA on the + [Stanford Sentiment Treebank dataset](https://nlp.stanford.edu/sentiment/index.html) which contains one-sentence movie reviews. A pre-trained neural network classifier is used, which identifies whether a movie review is positive or negative. + """) + if not (text_input and text_model_file and text_label_file): st.info('Add your input data in the left panel to continue') st.stop() From 710e1b0c17a6db4636eacb51bab6318cc922bd23 Mon Sep 17 00:00:00 2001 From: Laura Ootes Date: Wed, 31 Jul 2024 09:59:11 +0200 Subject: [PATCH 06/11] update example name --- dianna/dashboard/pages/Images.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dianna/dashboard/pages/Images.py b/dianna/dashboard/pages/Images.py index 1f538ead..996c9f69 100644 --- a/dianna/dashboard/pages/Images.py +++ b/dianna/dashboard/pages/Images.py @@ -19,25 +19,25 @@ st.sidebar.header('Input data') -load_example = st.sidebar.checkbox('Load example data', - key='Image_example_check') +load_example_digits = st.sidebar.checkbox('Load hand-written digits example', + key='Image_digits_example_check') image_file = st.sidebar.file_uploader('Select image', type=('png', 'jpg', 'jpeg'), - disabled=load_example) + disabled=load_example_digits) if image_file: st.sidebar.image(image_file) image_model_file = st.sidebar.file_uploader('Select model', type='onnx', - disabled=load_example) + disabled=load_example_digits) image_label_file = st.sidebar.file_uploader('Select labels', type='txt', - disabled=load_example) + disabled=load_example_digits) -if load_example: +if load_example_digits: image_file = (data_directory / 'digit0.jpg') image_model_file = (model_directory / 'mnist_model_tf.onnx') image_label_file = (label_directory / 'labels_mnist.txt') From d4d01d7b7cd6a9406d55e10ee42976b47a199b7e Mon Sep 17 00:00:00 2001 From: Laura Ootes Date: Wed, 31 Jul 2024 09:59:26 +0200 Subject: [PATCH 07/11] update key name for specific example --- dianna/dashboard/pages/Text.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dianna/dashboard/pages/Text.py b/dianna/dashboard/pages/Text.py index 95dbebda..cf326494 100644 --- a/dianna/dashboard/pages/Text.py +++ b/dianna/dashboard/pages/Text.py @@ -19,7 +19,7 @@ st.sidebar.header('Input data') load_example_moviesentiment = st.sidebar.checkbox('Load movie sentiment example', - key='Text_example_check') + key='Text_example_check_moviesentiment') text_input = st.sidebar.text_input('Input string', disabled=load_example_moviesentiment) From 3d28151113541076b7c18bd28203b6bc2c15b347 Mon Sep 17 00:00:00 2001 From: Laura Ootes Date: Wed, 31 Jul 2024 10:05:20 +0200 Subject: [PATCH 08/11] add explanatory text of mnist example --- dianna/dashboard/pages/Images.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dianna/dashboard/pages/Images.py b/dianna/dashboard/pages/Images.py index 996c9f69..a401cea3 100644 --- a/dianna/dashboard/pages/Images.py +++ b/dianna/dashboard/pages/Images.py @@ -42,6 +42,14 @@ image_model_file = (model_directory / 'mnist_model_tf.onnx') image_label_file = (label_directory / 'labels_mnist.txt') + st.markdown( + """ + This example demonstrates the use of DIANNA on a pretrained binary [MNIST](https://yann.lecun.com/exdb/mnist/) model using a hand-written digit images. + The model predict for an image of a hand-written 0 or 1, which of the two it most likely is. + This example visualizes the relevance attributions for each pixel/super-pixel by displaying them on top of the input image. + """ + ) + if not (image_file and image_model_file and image_label_file): st.info('Add your input data in the left panel to continue') st.stop() From 693b98d361b37dc1ef6e62b878ffa0485dfae5c4 Mon Sep 17 00:00:00 2001 From: Laura Ootes Date: Fri, 2 Aug 2024 14:55:52 +0200 Subject: [PATCH 09/11] fix line lengths --- dianna/dashboard/pages/Images.py | 9 ++++++--- dianna/dashboard/pages/Text.py | 7 +++++-- dianna/dashboard/pages/Time_series.py | 15 +++++++++------ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/dianna/dashboard/pages/Images.py b/dianna/dashboard/pages/Images.py index a401cea3..7d04a93e 100644 --- a/dianna/dashboard/pages/Images.py +++ b/dianna/dashboard/pages/Images.py @@ -44,9 +44,12 @@ st.markdown( """ - This example demonstrates the use of DIANNA on a pretrained binary [MNIST](https://yann.lecun.com/exdb/mnist/) model using a hand-written digit images. - The model predict for an image of a hand-written 0 or 1, which of the two it most likely is. - This example visualizes the relevance attributions for each pixel/super-pixel by displaying them on top of the input image. + This example demonstrates the use of DIANNA on a pretrained binary + [MNIST](https://yann.lecun.com/exdb/mnist/) model using a hand-written + digit images. The model predict for an image of a hand-written 0 or 1, + which of the two it most likely is. This example visualizes the + relevance attributions for each pixel/super-pixel by displaying them on + top of the input image. """ ) diff --git a/dianna/dashboard/pages/Text.py b/dianna/dashboard/pages/Text.py index cf326494..2de02a7c 100644 --- a/dianna/dashboard/pages/Text.py +++ b/dianna/dashboard/pages/Text.py @@ -41,8 +41,11 @@ st.markdown( """ - This example demonstrates the use of DIANNA on the - [Stanford Sentiment Treebank dataset](https://nlp.stanford.edu/sentiment/index.html) which contains one-sentence movie reviews. A pre-trained neural network classifier is used, which identifies whether a movie review is positive or negative. + This example demonstrates the use of DIANNA on the [Stanford Sentiment + Treebank dataset](https://nlp.stanford.edu/sentiment/index.html) which + contains one-sentence movie reviews. A pre-trained neural network + classifier is used, which identifies whether a movie review is positive + or negative. """) if not (text_input and text_model_file and text_label_file): diff --git a/dianna/dashboard/pages/Time_series.py b/dianna/dashboard/pages/Time_series.py index 9b780c15..d6e7d937 100644 --- a/dianna/dashboard/pages/Time_series.py +++ b/dianna/dashboard/pages/Time_series.py @@ -41,12 +41,15 @@ ts_label_file = (label_directory / 'weather_data_labels.txt') st.markdown( - """This example demonstrates the use of DIANNA - on a pre-trained binary classification model for season prediction. - The input data is the - [weather prediction dataset](https://zenodo.org/records/5071376). - This classification model uses time (days) as function of mean temperature to predict if the whole time series is either summer or winter. - Using a chosen XAI method the relevance scores are displayed on top of the timeseries. The days contributing positively towards the classification decision are indicated in red and those who contribute negatively in blue. + """This example demonstrates the use of DIANNA + on a pre-trained binary classification model for season prediction. The + input data is the [weather prediction + dataset](https://zenodo.org/records/5071376). This classification model + uses time (days) as function of mean temperature to predict if the whole + time series is either summer or winter. Using a chosen XAI method the + relevance scores are displayed on top of the timeseries. The days + contributing positively towards the classification decision are + indicated in red and those who contribute negatively in blue. """) if not (ts_file and ts_model_file and ts_label_file): From 5fae960cceb1c788fab391587f2d9f71d9d03207 Mon Sep 17 00:00:00 2001 From: Laura Ootes Date: Tue, 6 Aug 2024 15:42:01 +0200 Subject: [PATCH 10/11] update tests --- tests/test_dashboard.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_dashboard.py b/tests/test_dashboard.py index 9c5171fe..3fe76ae0 100644 --- a/tests/test_dashboard.py +++ b/tests/test_dashboard.py @@ -98,7 +98,7 @@ def test_text_page(page: Page): expect(selector).to_be_visible(timeout=30_000) page.locator('label').filter( - has_text='Load example data').locator('span').click() + has_text='Load movie sentiment example').locator('span').click() expect(page.get_by_text('Select a method to continue')).to_be_visible() @@ -139,7 +139,7 @@ def test_image_page(page: Page): ).to_be_visible(timeout=100_000) page.locator('label').filter( - has_text='Load example data').locator('span').click() + has_text='Load hand-written digits example').locator('span').click() expect(page.get_by_text('Select a method to continue')).to_be_visible() @@ -180,7 +180,7 @@ def test_timeseries_page(page: Page): ).to_be_visible() page.locator('label').filter( - has_text='Load example data').locator('span').click() + has_text='Load weather example').locator('span').click() expect(page.get_by_text('Select a method to continue')).to_be_visible() From 4b56ef14f525a4fe892159c493e112a84ea569e4 Mon Sep 17 00:00:00 2001 From: Laura Ootes Date: Wed, 7 Aug 2024 11:43:50 +0200 Subject: [PATCH 11/11] fix typos --- dianna/dashboard/pages/Images.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dianna/dashboard/pages/Images.py b/dianna/dashboard/pages/Images.py index 7d04a93e..94c55bef 100644 --- a/dianna/dashboard/pages/Images.py +++ b/dianna/dashboard/pages/Images.py @@ -45,8 +45,8 @@ st.markdown( """ This example demonstrates the use of DIANNA on a pretrained binary - [MNIST](https://yann.lecun.com/exdb/mnist/) model using a hand-written - digit images. The model predict for an image of a hand-written 0 or 1, + [MNIST](https://yann.lecun.com/exdb/mnist/) model using hand-written + digit images. The model predicts for an image of a hand-written 0 or 1, which of the two it most likely is. This example visualizes the relevance attributions for each pixel/super-pixel by displaying them on top of the input image.