Skip to content

Commit

Permalink
Refactor dependencies and add new code in backend and frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik172 committed May 5, 2024
1 parent 0d6edda commit bcd961f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
3 changes: 2 additions & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ python-dotenv
pandas
torch
ultralytics>=8.1.45
sentry-sdk
sentry-sdk
pymongo
9 changes: 7 additions & 2 deletions frontend/pages/auditoria.py
Original file line number Diff line number Diff line change
@@ -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="🔍",
Expand Down
21 changes: 10 additions & 11 deletions frontend/pages/rode.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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)}**')

Expand Down Expand Up @@ -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:
Expand All @@ -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')

Expand Down
3 changes: 1 addition & 2 deletions frontend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ matplotlib
opencv-python
sentry-sdk
numpy
pytesseract
dask
pytesseract

0 comments on commit bcd961f

Please sign in to comment.