From 4d4a6c605bbe1ae52ff2c6b6d7114563c977b577 Mon Sep 17 00:00:00 2001 From: yashksaini-coder Date: Mon, 14 Oct 2024 20:57:35 +0530 Subject: [PATCH 01/26] update gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index a0685c32..6a1f80fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ __pycache__ venv *.log + +env/ \ No newline at end of file From 8be6dd2d673cd444d87287b6e1014169a9d199c9 Mon Sep 17 00:00:00 2001 From: yashksaini-coder Date: Mon, 14 Oct 2024 21:05:05 +0530 Subject: [PATCH 02/26] Add tensorflow in requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index d43fe9e5..44f9496f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -122,6 +122,7 @@ streamlit==1.38.0 tenacity==8.5.0 terminado==0.18.1 threadpoolctl==3.5.0 +tensorflow tinycss2==1.3.0 toml==0.10.2 tornado==6.4.1 From 8e94782a57e0cd744644f272301c78f63dc4e077 Mon Sep 17 00:00:00 2001 From: yashksaini-coder Date: Mon, 14 Oct 2024 22:30:35 +0530 Subject: [PATCH 03/26] Add Landmark-detection data --- pages/Landmark_Detection.py | 4 ++++ pages/pages.json | 25 ++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 pages/Landmark_Detection.py diff --git a/pages/Landmark_Detection.py b/pages/Landmark_Detection.py new file mode 100644 index 00000000..46519c53 --- /dev/null +++ b/pages/Landmark_Detection.py @@ -0,0 +1,4 @@ +from page_handler import PageHandler + +page_handler = PageHandler("pages/pages.json") +page_handler.render_page("Landmark Detection") diff --git a/pages/pages.json b/pages/pages.json index 9e3f508a..6db516cc 100644 --- a/pages/pages.json +++ b/pages/pages.json @@ -150,5 +150,28 @@ "type": "model_details" } ] -} +}, + "Landmark Detection": { + "title": "Landmark Detection", + "page_title": "Landmark Detection", + "page_icon": "\ud83d\udd12", + "model_predict_file_path": "models/landmark_detection/predict.py", + "model_function": "classify_image", + "form_config_path": "form_configs/landmark_detection.json", + "tabs": [ + { + "name": "Landmark Detection Form", + "type": "form", + "form_name": "Landmark Detection Form" + }, + { + "name": "Model Details", + "type": "model_details", + "problem_statement": "The model predicts the landmark present in an image.", + "description": "This model uses a pre-trained deep learning model to classify images and identify landmarks." + } + ] + } + + } From 0f5535ff449f526c77c587743702e9460f4bda39 Mon Sep 17 00:00:00 2001 From: yashksaini-coder Date: Mon, 14 Oct 2024 22:31:19 +0530 Subject: [PATCH 04/26] Created the image processing & predict function --- models/landmark_detection/predict.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 models/landmark_detection/predict.py diff --git a/models/landmark_detection/predict.py b/models/landmark_detection/predict.py new file mode 100644 index 00000000..d21ea522 --- /dev/null +++ b/models/landmark_detection/predict.py @@ -0,0 +1,26 @@ +import pandas as pd +import numpy as np +import tensorflow as tf +import tensorflow_hub as hub +from PIL import Image # Importing PIL for image processing + +# Load the model +TF_MODEL_URL = 'https://tfhub.dev/google/on_device_vision/classifier/landmarks_classifier_asia_V1/1' +LABEL_MAP_URL = 'https://www.gstatic.com/aihub/tfhub/labelmaps/landmarks_classifier_asia_V1_label_map.csv' +IMAGE_SHAPE = (321, 321) +df = pd.read_csv(LABEL_MAP_URL) +label_map = dict(zip(df.id, df.name)) + +classifier = tf.keras.Sequential([ + tf.keras.layers.InputLayer(shape=IMAGE_SHAPE+(3,)), + tf.keras.layers.Lambda(lambda x: hub.KerasLayer(TF_MODEL_URL, output_key='predictions:logits')(x)) +]) + +def get_prediction(image): + # Open the uploaded image file + img = Image.open(image) + img = img.resize(IMAGE_SHAPE) # Resize the image to the expected shape + img = np.array(img) / 255.0 # Convert to array and normalize + img = img[np.newaxis, ...] # Add batch dimension + prediction = classifier.predict(img) + return label_map[np.argmax(prediction)] From 4a83f23fb918ebda8fdcb0b4ea94f321143d3b1f Mon Sep 17 00:00:00 2001 From: yashksaini-coder Date: Mon, 14 Oct 2024 22:32:07 +0530 Subject: [PATCH 05/26] initialized landmark-detection json schema --- form_configs/landmark_detection.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 form_configs/landmark_detection.json diff --git a/form_configs/landmark_detection.json b/form_configs/landmark_detection.json new file mode 100644 index 00000000..ef97b5f9 --- /dev/null +++ b/form_configs/landmark_detection.json @@ -0,0 +1,10 @@ +{ + "Landmark Detection Form": { + "image": { + "field_name": "image", + "type": "file", + "accept": "image/*", + "required": true + } + } +} \ No newline at end of file From 0f6364e2be69084b9b9afc405e12b7a4ff78e156 Mon Sep 17 00:00:00 2001 From: yashksaini-coder Date: Mon, 14 Oct 2024 22:32:31 +0530 Subject: [PATCH 06/26] Performed final checks all completed --- .vscode/settings.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..45355212 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "cSpell.words": [ + "newaxis" + ] +} \ No newline at end of file From 5ff0d17a2fb07653a3f5b9c9bf15b974e069b097 Mon Sep 17 00:00:00 2001 From: Peart-Guy Date: Mon, 14 Oct 2024 22:43:43 +0530 Subject: [PATCH 07/26] Text Summarization Model --- App.py | 13 ++++++++++++ models/text_sumarization/predict.py | 31 +++++++++++++++++++++++++++++ pages/Text Summarizer.py | 31 +++++++++++++++++++++++++++++ requirements.txt | 2 ++ 4 files changed, 77 insertions(+) create mode 100644 models/text_sumarization/predict.py create mode 100644 pages/Text Summarizer.py diff --git a/App.py b/App.py index dd8f9180..cc5ab1aa 100644 --- a/App.py +++ b/App.py @@ -107,3 +107,16 @@ - **GLD**: The price of SPDR Gold Shares (GLD), which is the target variable representing gold prices. """ ) + +#Text Summarization Section + +st.write( + "- *Text Summarizer*: Save time with concise, professional summaries of lengthy texts—tailored to meet your needs and streamline your reading experience." +) +with st.expander("Text Summarizer - More Information"): + st.subheader("Introduction") + st.write( + """ + Many struggle with summarizing large texts or learning from lengthy materials. This model simplifies the process, offering concise summaries that enhance understanding and speed up learning—perfect for students and professionals alike. + """ + ) \ No newline at end of file diff --git a/models/text_sumarization/predict.py b/models/text_sumarization/predict.py new file mode 100644 index 00000000..70fcae82 --- /dev/null +++ b/models/text_sumarization/predict.py @@ -0,0 +1,31 @@ +import streamlit as st +from transformers import pipeline + +# Title of the web app +st.title("Text Summarization Tool") + +# Load the summarization model +@st.cache_resource(show_spinner=True) # Cache the model loading for faster performance +def load_summarizer(): + return pipeline("summarization", model="t5-small") + +summarizer = load_summarizer() + +# Instructions for users +st.write("Enter the text you'd like to summarize (minimum 50 words).") + +# Create a text area for the user to input text +user_input = st.text_area("Input Text", height=200) + +# A button to initiate the summarization process +if st.button("Summarize"): + if len(user_input.split()) < 50: + st.warning("Please enter at least 50 words for summarization.") + else: + # Show a spinner while the summarization is being processed + with st.spinner("Summarizing..."): + # Generate the summary + summary = summarizer(user_input, max_length=150, min_length=30, do_sample=False) + # Display the summarized text + st.subheader("Summary:") + st.write(summary[0]['summary_text']) diff --git a/pages/Text Summarizer.py b/pages/Text Summarizer.py new file mode 100644 index 00000000..70fcae82 --- /dev/null +++ b/pages/Text Summarizer.py @@ -0,0 +1,31 @@ +import streamlit as st +from transformers import pipeline + +# Title of the web app +st.title("Text Summarization Tool") + +# Load the summarization model +@st.cache_resource(show_spinner=True) # Cache the model loading for faster performance +def load_summarizer(): + return pipeline("summarization", model="t5-small") + +summarizer = load_summarizer() + +# Instructions for users +st.write("Enter the text you'd like to summarize (minimum 50 words).") + +# Create a text area for the user to input text +user_input = st.text_area("Input Text", height=200) + +# A button to initiate the summarization process +if st.button("Summarize"): + if len(user_input.split()) < 50: + st.warning("Please enter at least 50 words for summarization.") + else: + # Show a spinner while the summarization is being processed + with st.spinner("Summarizing..."): + # Generate the summary + summary = summarizer(user_input, max_length=150, min_length=30, do_sample=False) + # Display the summarized text + st.subheader("Summary:") + st.write(summary[0]['summary_text']) diff --git a/requirements.txt b/requirements.txt index d43fe9e5..92f5ad14 100644 --- a/requirements.txt +++ b/requirements.txt @@ -138,3 +138,5 @@ webcolors==24.8.0 webencodings==0.5.1 websocket-client==1.8.0 xgboost==2.1.1 +transformers==4.45.2 +tf_keras==2.17.0 \ No newline at end of file From 6636ee35ee04f1ae3a22d69ff1b2f6d9bccef653 Mon Sep 17 00:00:00 2001 From: Yashasvini Sharma <100478608+yashasvini121@users.noreply.github.com> Date: Wed, 16 Oct 2024 23:45:35 +0530 Subject: [PATCH 08/26] Delete devcontainer.json --- .devcontainer/devcontainer.json | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index 84918163..00000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "Python 3", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", - "customizations": { - "codespaces": { - "openFiles": [ - "README.md", - "app.py" - ] - }, - "vscode": { - "settings": {}, - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance" - ] - } - }, - "updateContentCommand": "[ -f packages.txt ] && sudo apt update && sudo apt upgrade -y && sudo xargs apt install -y Date: Thu, 17 Oct 2024 23:16:19 +0530 Subject: [PATCH 09/26] Delete .vscode/settings.json --- .vscode/settings.json | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 45355212..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "cSpell.words": [ - "newaxis" - ] -} \ No newline at end of file From 4c0257f824e09ff9d1c6ae8b18bf198771d675e7 Mon Sep 17 00:00:00 2001 From: Yashasvini Sharma <100478608+yashasvini121@users.noreply.github.com> Date: Thu, 17 Oct 2024 23:16:36 +0530 Subject: [PATCH 10/26] Delete .gitignore --- .gitignore | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 6a1f80fa..00000000 --- a/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -__pycache__ -venv -*.log - -env/ \ No newline at end of file From 0e05b24de26d8d90133560664ae0e14bffe6e764 Mon Sep 17 00:00:00 2001 From: Yashasvini Sharma <100478608+yashasvini121@users.noreply.github.com> Date: Fri, 18 Oct 2024 23:34:23 +0530 Subject: [PATCH 11/26] Add gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..d9d719b4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__ +*.log From 8c38d601cfd1678c99fe6ed2736de4b22d15bede Mon Sep 17 00:00:00 2001 From: Yashasvini Sharma <100478608+yashasvini121@users.noreply.github.com> Date: Fri, 18 Oct 2024 23:35:25 +0530 Subject: [PATCH 12/26] Add dev-requirements --- dev-requirements.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 dev-requirements.txt diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 00000000..1e56bbc4 --- /dev/null +++ b/dev-requirements.txt @@ -0,0 +1,10 @@ +# Development dependencies for the project. +# Includes Jupyter and other tools used during development, but not required for the Streamlit app in production. + +jupyterlab +notebook + +# jupyterlab==4.2.5 +# jupyterlab_pygments==0.3.0 +# jupyterlab_server==2.27.3 +# jupyterlab_widgets==3.0.13 \ No newline at end of file From 06e1fe3e8a690eb76fade84aa23c1db78f951bc0 Mon Sep 17 00:00:00 2001 From: Yashasvini Sharma <100478608+yashasvini121@users.noreply.github.com> Date: Sat, 19 Oct 2024 00:08:43 +0530 Subject: [PATCH 13/26] Add Validate PR Workflow --- .github/workflows/validate-pr.yaml | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/validate-pr.yaml diff --git a/.github/workflows/validate-pr.yaml b/.github/workflows/validate-pr.yaml new file mode 100644 index 00000000..48de2281 --- /dev/null +++ b/.github/workflows/validate-pr.yaml @@ -0,0 +1,45 @@ +name: CI - Validate PR + +# Trigger the workflow on pull requests to the main branch +on: + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: [3.12] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + architecture: 'x64' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Validate dependencies with pip-check + run: | + pip install pip-check + pip-check + continue-on-error: false # Fail the workflow if dependencies are invalid + + - name: Test Streamlit App + run: | + pip install streamlit + streamlit run app.py --server.headless true --browser.gatherUsageStats false & + sleep 10 # Wait for the app to start + curl --retry 5 --retry-delay 5 http://localhost:8501 + env: + STREAMLIT_SERVER_HEADLESS: true \ No newline at end of file From ccb79601ff8cbe9daa9f6629fc8e96197d8e0cdd Mon Sep 17 00:00:00 2001 From: Yashasvini Sharma <100478608+yashasvini121@users.noreply.github.com> Date: Sat, 19 Oct 2024 00:21:48 +0530 Subject: [PATCH 14/26] Update workflows --- .github/workflows/validate-pr.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate-pr.yaml b/.github/workflows/validate-pr.yaml index 48de2281..418efe19 100644 --- a/.github/workflows/validate-pr.yaml +++ b/.github/workflows/validate-pr.yaml @@ -1,9 +1,9 @@ -name: CI - Validate PR +name: Validate PR # Trigger the workflow on pull requests to the main branch on: pull_request: - branches: [ main ] + branches: [ master ] jobs: build: From 64cb63fe6fd84aab2d2e422425c498ac5cf3f581 Mon Sep 17 00:00:00 2001 From: Yashasvini Sharma <100478608+yashasvini121@users.noreply.github.com> Date: Sat, 19 Oct 2024 00:30:28 +0530 Subject: [PATCH 15/26] Update validate-pr.yaml with types --- .github/workflows/validate-pr.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/validate-pr.yaml b/.github/workflows/validate-pr.yaml index 418efe19..2225cc2b 100644 --- a/.github/workflows/validate-pr.yaml +++ b/.github/workflows/validate-pr.yaml @@ -4,6 +4,7 @@ name: Validate PR on: pull_request: branches: [ master ] + types: [opened, synchronize, reopened, ready_for_review] jobs: build: @@ -42,4 +43,4 @@ jobs: sleep 10 # Wait for the app to start curl --retry 5 --retry-delay 5 http://localhost:8501 env: - STREAMLIT_SERVER_HEADLESS: true \ No newline at end of file + STREAMLIT_SERVER_HEADLESS: true From be8b512f3338b6537ff1f08337836f18b7ecf3d6 Mon Sep 17 00:00:00 2001 From: Yash Kumar Saini <115717039+yashksaini-coder@users.noreply.github.com> Date: Fri, 18 Oct 2024 19:26:54 +0000 Subject: [PATCH 16/26] Remove the Landmark detection web-app --- form_configs/landmark_detection.json | 10 ---------- models/landmark_detection/predict.py | 26 -------------------------- pages/Landmark_Detection.py | 4 ---- pages/pages.json | 24 +----------------------- 4 files changed, 1 insertion(+), 63 deletions(-) delete mode 100644 form_configs/landmark_detection.json delete mode 100644 models/landmark_detection/predict.py delete mode 100644 pages/Landmark_Detection.py diff --git a/form_configs/landmark_detection.json b/form_configs/landmark_detection.json deleted file mode 100644 index ef97b5f9..00000000 --- a/form_configs/landmark_detection.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "Landmark Detection Form": { - "image": { - "field_name": "image", - "type": "file", - "accept": "image/*", - "required": true - } - } -} \ No newline at end of file diff --git a/models/landmark_detection/predict.py b/models/landmark_detection/predict.py deleted file mode 100644 index d21ea522..00000000 --- a/models/landmark_detection/predict.py +++ /dev/null @@ -1,26 +0,0 @@ -import pandas as pd -import numpy as np -import tensorflow as tf -import tensorflow_hub as hub -from PIL import Image # Importing PIL for image processing - -# Load the model -TF_MODEL_URL = 'https://tfhub.dev/google/on_device_vision/classifier/landmarks_classifier_asia_V1/1' -LABEL_MAP_URL = 'https://www.gstatic.com/aihub/tfhub/labelmaps/landmarks_classifier_asia_V1_label_map.csv' -IMAGE_SHAPE = (321, 321) -df = pd.read_csv(LABEL_MAP_URL) -label_map = dict(zip(df.id, df.name)) - -classifier = tf.keras.Sequential([ - tf.keras.layers.InputLayer(shape=IMAGE_SHAPE+(3,)), - tf.keras.layers.Lambda(lambda x: hub.KerasLayer(TF_MODEL_URL, output_key='predictions:logits')(x)) -]) - -def get_prediction(image): - # Open the uploaded image file - img = Image.open(image) - img = img.resize(IMAGE_SHAPE) # Resize the image to the expected shape - img = np.array(img) / 255.0 # Convert to array and normalize - img = img[np.newaxis, ...] # Add batch dimension - prediction = classifier.predict(img) - return label_map[np.argmax(prediction)] diff --git a/pages/Landmark_Detection.py b/pages/Landmark_Detection.py deleted file mode 100644 index 46519c53..00000000 --- a/pages/Landmark_Detection.py +++ /dev/null @@ -1,4 +0,0 @@ -from page_handler import PageHandler - -page_handler = PageHandler("pages/pages.json") -page_handler.render_page("Landmark Detection") diff --git a/pages/pages.json b/pages/pages.json index 6db516cc..e52400f7 100644 --- a/pages/pages.json +++ b/pages/pages.json @@ -150,28 +150,6 @@ "type": "model_details" } ] -}, - "Landmark Detection": { - "title": "Landmark Detection", - "page_title": "Landmark Detection", - "page_icon": "\ud83d\udd12", - "model_predict_file_path": "models/landmark_detection/predict.py", - "model_function": "classify_image", - "form_config_path": "form_configs/landmark_detection.json", - "tabs": [ - { - "name": "Landmark Detection Form", - "type": "form", - "form_name": "Landmark Detection Form" - }, - { - "name": "Model Details", - "type": "model_details", - "problem_statement": "The model predicts the landmark present in an image.", - "description": "This model uses a pre-trained deep learning model to classify images and identify landmarks." - } - ] - } - +} } From 5faca481bff00e1297c70a9f395cc5248734394b Mon Sep 17 00:00:00 2001 From: Yashasvini Sharma <100478608+yashasvini121@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:10:33 +0530 Subject: [PATCH 17/26] Add install packages.txt to validate-pr.yaml --- .github/workflows/validate-pr.yaml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/validate-pr.yaml b/.github/workflows/validate-pr.yaml index 2225cc2b..c5f6f0d0 100644 --- a/.github/workflows/validate-pr.yaml +++ b/.github/workflows/validate-pr.yaml @@ -1,6 +1,5 @@ name: Validate PR -# Trigger the workflow on pull requests to the main branch on: pull_request: branches: [ master ] @@ -19,13 +18,19 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + - name: Install Ubuntu packages + run: | + sudo apt-get update + sudo xargs -a packages.txt apt-get install -y + shell: bash + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - architecture: 'x64' + architecture: 'x64' - - name: Install dependencies + - name: Install Python dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt From 34b313bc9bb4d6e395c5cc7d3c5c440f424e3420 Mon Sep 17 00:00:00 2001 From: Yashasvini Sharma <100478608+yashasvini121@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:13:54 +0530 Subject: [PATCH 18/26] Remove numpy, protobuf, tensorflow versions from requirements.txt --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 44f9496f..5c5185a0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -63,7 +63,7 @@ matplotlib-inline==0.1.7 mdurl==0.1.2 mistune==3.0.2 narwhals==1.8.1 -numpy==2.1.1 +numpy openpyxl==3.1.5 overrides==7.7.0 packaging==24.1 @@ -78,7 +78,7 @@ pluggy==1.5.0 prometheus_client==0.20.0 prompt_toolkit==3.0.47 prophet==1.1.6 -protobuf==5.28.2 +protobuf psutil==6.0.0 pure_eval==0.2.3 pyarrow==17.0.0 From daa8e02c0eac7c301d49adcd6b4f348f0676ea9a Mon Sep 17 00:00:00 2001 From: Yashasvini Sharma <100478608+yashasvini121@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:18:06 +0530 Subject: [PATCH 19/26] Add tensorrt to requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 5c5185a0..114eef5e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -123,6 +123,7 @@ tenacity==8.5.0 terminado==0.18.1 threadpoolctl==3.5.0 tensorflow +tensorrt tinycss2==1.3.0 toml==0.10.2 tornado==6.4.1 From caad2a8599b744ad9940727044a9d7a7b1cf29b6 Mon Sep 17 00:00:00 2001 From: Yashasvini Sharma <100478608+yashasvini121@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:19:15 +0530 Subject: [PATCH 20/26] Add tensorflow-hub to requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 114eef5e..4e0dce9b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -123,6 +123,7 @@ tenacity==8.5.0 terminado==0.18.1 threadpoolctl==3.5.0 tensorflow +tensorflow-hub tensorrt tinycss2==1.3.0 toml==0.10.2 From b4e75a5d89b17595da42ede32d818a3ff7bcb259 Mon Sep 17 00:00:00 2001 From: Yashasvini Sharma <100478608+yashasvini121@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:34:58 +0530 Subject: [PATCH 21/26] Add numpy, protobuf versions and remove tensorflow, tensorflow-hub from requirements.txt --- requirements.txt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index 4e0dce9b..d43fe9e5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -63,7 +63,7 @@ matplotlib-inline==0.1.7 mdurl==0.1.2 mistune==3.0.2 narwhals==1.8.1 -numpy +numpy==2.1.1 openpyxl==3.1.5 overrides==7.7.0 packaging==24.1 @@ -78,7 +78,7 @@ pluggy==1.5.0 prometheus_client==0.20.0 prompt_toolkit==3.0.47 prophet==1.1.6 -protobuf +protobuf==5.28.2 psutil==6.0.0 pure_eval==0.2.3 pyarrow==17.0.0 @@ -122,9 +122,6 @@ streamlit==1.38.0 tenacity==8.5.0 terminado==0.18.1 threadpoolctl==3.5.0 -tensorflow -tensorflow-hub -tensorrt tinycss2==1.3.0 toml==0.10.2 tornado==6.4.1 From 5c96bbdd2f6579f168467192275cfd087f0d2afe Mon Sep 17 00:00:00 2001 From: Yashasvini Sharma <100478608+yashasvini121@users.noreply.github.com> Date: Sat, 19 Oct 2024 12:38:12 +0530 Subject: [PATCH 22/26] Change app.py to App.py in workflow --- .github/workflows/validate-pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate-pr.yaml b/.github/workflows/validate-pr.yaml index c5f6f0d0..885586f5 100644 --- a/.github/workflows/validate-pr.yaml +++ b/.github/workflows/validate-pr.yaml @@ -44,7 +44,7 @@ jobs: - name: Test Streamlit App run: | pip install streamlit - streamlit run app.py --server.headless true --browser.gatherUsageStats false & + streamlit run App.py --server.headless true --browser.gatherUsageStats false & sleep 10 # Wait for the app to start curl --retry 5 --retry-delay 5 http://localhost:8501 env: From 7f86ba29dac2fb2710ff4067559f1f6f4b9f823f Mon Sep 17 00:00:00 2001 From: Yashasvini Sharma <100478608+yashasvini121@users.noreply.github.com> Date: Sat, 19 Oct 2024 13:21:20 +0530 Subject: [PATCH 23/26] Update Text Summarizer.py --- pages/Text Summarizer.py | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/pages/Text Summarizer.py b/pages/Text Summarizer.py index 70fcae82..58a1a502 100644 --- a/pages/Text Summarizer.py +++ b/pages/Text Summarizer.py @@ -1,31 +1,19 @@ import streamlit as st -from transformers import pipeline +from models.text_sumarization.predict import generate_summary -# Title of the web app st.title("Text Summarization Tool") -# Load the summarization model -@st.cache_resource(show_spinner=True) # Cache the model loading for faster performance -def load_summarizer(): - return pipeline("summarization", model="t5-small") - -summarizer = load_summarizer() - -# Instructions for users st.write("Enter the text you'd like to summarize (minimum 50 words).") -# Create a text area for the user to input text -user_input = st.text_area("Input Text", height=200) +user_input = st.text_area("Input Text", height=250) # A button to initiate the summarization process if st.button("Summarize"): - if len(user_input.split()) < 50: - st.warning("Please enter at least 50 words for summarization.") - else: - # Show a spinner while the summarization is being processed - with st.spinner("Summarizing..."): - # Generate the summary - summary = summarizer(user_input, max_length=150, min_length=30, do_sample=False) - # Display the summarized text - st.subheader("Summary:") - st.write(summary[0]['summary_text']) + if len(user_input.split()) < 50: + st.warning("Please enter at least 50 words for summarization.") + else: + # Show a spinner while the summarization is being processed + with st.spinner("Summarizing..."): + summary = generate_summary(user_input) # Call the function from predict.py + st.subheader("Summary:") + st.code(summary, language="text", wrap_lines=True) From 876b138e36ad5445dcb560727db7cb716bfe392b Mon Sep 17 00:00:00 2001 From: Yashasvini Sharma <100478608+yashasvini121@users.noreply.github.com> Date: Sat, 19 Oct 2024 13:22:02 +0530 Subject: [PATCH 24/26] Update predict.py --- models/text_sumarization/predict.py | 36 ++++++++--------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/models/text_sumarization/predict.py b/models/text_sumarization/predict.py index 70fcae82..826801ce 100644 --- a/models/text_sumarization/predict.py +++ b/models/text_sumarization/predict.py @@ -1,31 +1,13 @@ -import streamlit as st from transformers import pipeline +import streamlit as st -# Title of the web app -st.title("Text Summarization Tool") - -# Load the summarization model @st.cache_resource(show_spinner=True) # Cache the model loading for faster performance def load_summarizer(): - return pipeline("summarization", model="t5-small") - -summarizer = load_summarizer() - -# Instructions for users -st.write("Enter the text you'd like to summarize (minimum 50 words).") - -# Create a text area for the user to input text -user_input = st.text_area("Input Text", height=200) - -# A button to initiate the summarization process -if st.button("Summarize"): - if len(user_input.split()) < 50: - st.warning("Please enter at least 50 words for summarization.") - else: - # Show a spinner while the summarization is being processed - with st.spinner("Summarizing..."): - # Generate the summary - summary = summarizer(user_input, max_length=150, min_length=30, do_sample=False) - # Display the summarized text - st.subheader("Summary:") - st.write(summary[0]['summary_text']) + """Load and cache the text summarization pipeline model.""" + return pipeline("summarization", model="t5-small") + +def generate_summary(text: str) -> str: + """Generate a summary for the given input text.""" + summarizer = load_summarizer() + summary = summarizer(text, max_length=150, min_length=30, do_sample=False) + return summary[0]["summary_text"] From 3b8b5c3483e2ed3a1d1ad3f0e4e248bbb728243f Mon Sep 17 00:00:00 2001 From: Yashasvini Sharma <100478608+yashasvini121@users.noreply.github.com> Date: Sat, 19 Oct 2024 13:31:11 +0530 Subject: [PATCH 25/26] Update protobuf version from 5.28.2 to 4.25.5 in requirements --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 92f5ad14..79567a5c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -78,7 +78,7 @@ pluggy==1.5.0 prometheus_client==0.20.0 prompt_toolkit==3.0.47 prophet==1.1.6 -protobuf==5.28.2 +protobuf==4.25.5 psutil==6.0.0 pure_eval==0.2.3 pyarrow==17.0.0 @@ -139,4 +139,4 @@ webencodings==0.5.1 websocket-client==1.8.0 xgboost==2.1.1 transformers==4.45.2 -tf_keras==2.17.0 \ No newline at end of file +tf_keras==2.17.0 From cca96b3471b4a9b5e50377f706ec5e6ed73ad6a9 Mon Sep 17 00:00:00 2001 From: Yashasvini Sharma <100478608+yashasvini121@users.noreply.github.com> Date: Sat, 19 Oct 2024 13:42:46 +0530 Subject: [PATCH 26/26] Remove numpy version in requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 79567a5c..ac7563bf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -63,7 +63,7 @@ matplotlib-inline==0.1.7 mdurl==0.1.2 mistune==3.0.2 narwhals==1.8.1 -numpy==2.1.1 +numpy openpyxl==3.1.5 overrides==7.7.0 packaging==24.1