From bcd961f85dc3fe409f43e420a35899a70fba8a2b Mon Sep 17 00:00:00 2001 From: zer0 Date: Sun, 5 May 2024 11:40:41 -0500 Subject: [PATCH] Refactor dependencies and add new code in backend and frontend --- backend/requirements.txt | 3 ++- frontend/pages/auditoria.py | 9 +++++++-- frontend/pages/rode.py | 21 ++++++++++----------- frontend/requirements.txt | 3 +-- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/backend/requirements.txt b/backend/requirements.txt index d18989a..83f5fbc 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -4,4 +4,5 @@ python-dotenv pandas torch ultralytics>=8.1.45 -sentry-sdk \ No newline at end of file +sentry-sdk +pymongo \ No newline at end of file diff --git a/frontend/pages/auditoria.py b/frontend/pages/auditoria.py index db19e92..ae2e875 100644 --- a/frontend/pages/auditoria.py +++ b/frontend/pages/auditoria.py @@ -1,11 +1,16 @@ from pdf2image import convert_from_bytes -from dask.distributed import Client import streamlit as st import pandas as pd -import dask.dataframe as dd import requests import os +from resources import ( + single_model_metrics, + hoja_control, + procces_image_rode, + procces_pdf2image_rode +) + st.set_page_config( page_title="Auditoría", page_icon="🔍", diff --git a/frontend/pages/rode.py b/frontend/pages/rode.py index 6556668..0898dff 100644 --- a/frontend/pages/rode.py +++ b/frontend/pages/rode.py @@ -1,6 +1,5 @@ from pdf2image import convert_from_bytes from datetime import datetime -import dask.dataframe as dd import streamlit as st import pandas as pd import os @@ -41,8 +40,8 @@ alerts = st.empty() -dataframe = dd.from_pandas(pd.DataFrame(columns=["archivo", "predicción", "confianza", "tiempo(s)"]), npartitions=1) -bad_dataframe = dd.from_pandas(pd.DataFrame(columns=["archivo", "predicción", "confianza", "tiempo(s)"]), npartitions=1) +dataframe = pd.DataFrame(columns=["archivo", "predicción", "confianza", "tiempo(s)"]) +bad_dataframe = pd.DataFrame(columns=["archivo", "predicción", "confianza", "tiempo(s)"]) def process_uploaded_images(uploaded_file, show_image, version="v1"): global bad_dataframe @@ -73,10 +72,10 @@ def process_uploaded_images(uploaded_file, show_image, version="v1"): if version == "v1": single_model_metrics(response) - dataframe = dd.concat([dataframe, dd.from_pandas(pd.DataFrame(data), npartitions=1)], axis=0) + dataframe = pd.concat([dataframe, pd.DataFrame(data)], axis=0) if response['data'][0]['name'] == "rotado": - bad_dataframe = dd.concat([bad_dataframe, dd.from_pandas(pd.DataFrame(data), npartitions=1)], axis=0) + bad_dataframe = pd.concat([bad_dataframe, pd.DataFrame(data)], axis=0) st.error(f':warning: La imagen "**{file.name}**" está rotada.') if show_image: @@ -87,8 +86,8 @@ def process_uploaded_images(uploaded_file, show_image, version="v1"): st.divider() - placeholder.dataframe(dataframe.compute()) - bad_placeholder.dataframe(bad_dataframe.compute()) + placeholder.dataframe(dataframe) + bad_placeholder.dataframe(bad_dataframe) fin_process.info(f'Fin del procesamiento: **{datetime.now().strftime("%Y-%m-%d %H:%M:%S")}**, tiempo total (Segundos): **{round((datetime.now() - inicio_time).total_seconds(), 2)}**') @@ -119,10 +118,10 @@ def process_pdf_file(uploaded_pdf, show_image, version="v1"): if version == "v1": single_model_metrics(response) - dataframe = dd.concat([dataframe, dd.from_pandas(pd.DataFrame(data), npartitions=1)], axis=0) + dataframe = pd.concat([dataframe, pd.DataFrame(data)], axis=0) if response['data'][0]['name'] == "rotado": - bad_dataframe = dd.concat([bad_dataframe, dd.from_pandas(pd.DataFrame(data), npartitions=1)], axis=0) + bad_dataframe = pd.concat([bad_dataframe, pd.DataFrame(data)], axis=0) st.error(f':warning: La Página **{i + 1}** en el PDF está rotada.') if show_image: @@ -138,8 +137,8 @@ def process_pdf_file(uploaded_pdf, show_image, version="v1"): st.divider() - placeholder.dataframe(dataframe.compute()) - bad_placeholder.dataframe(bad_dataframe.compute()) + placeholder.dataframe(dataframe) + bad_placeholder.dataframe(bad_dataframe) fin_process.info(f'Fin del procesamiento: **{datetime.now().strftime("%Y-%m-%d %H:%M:%S")}**, tiempo total: **{(datetime.now() - inicio_time).total_seconds()}** Segundos') diff --git a/frontend/requirements.txt b/frontend/requirements.txt index ceb67e5..8d90c8f 100644 --- a/frontend/requirements.txt +++ b/frontend/requirements.txt @@ -6,5 +6,4 @@ matplotlib opencv-python sentry-sdk numpy -pytesseract -dask \ No newline at end of file +pytesseract \ No newline at end of file