-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor file handling and add dependencies in frontend/requirements.txt
- Loading branch information
Showing
5 changed files
with
95 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ matplotlib | |
opencv-python | ||
sentry-sdk | ||
numpy | ||
pytesseract | ||
pytesseract | ||
dask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from .process_files import ImageProccesing | ||
from datetime import datetime | ||
import streamlit as st | ||
import random | ||
|
||
def procces_image_rode(image, name, version="v1"): | ||
response = ImageProccesing("rode").process_file(image, version) | ||
|
||
# cambiar nombres a español | ||
response['data'][0]['name'] = "rotado" if response['data'][0]['name'] == "rotated" else "no rotado" | ||
response['data'][1]['name'] = "rotado" if response['data'][1]['name'] == "rotated" else "no rotado" | ||
|
||
data = { | ||
"archivo": [name], | ||
"predicción": [response['data'][0]['name']], | ||
"confianza": [response['data'][0]['confidence'] * 100], | ||
"tiempo(s)": [response['time']], | ||
"fecha": [datetime.now().strftime("%Y-%m-%d %H:%M:%S")] | ||
} | ||
|
||
return data, response | ||
|
||
def procces_pdf2image_rode(image, name, version="v1", i=0): | ||
name_file_rand = f'temp/{"".join(random.choices("abcdefghijklmnopqrstuvwxyz", k=10))}.jpg' | ||
image.save(name_file_rand) | ||
image_path = name_file_rand | ||
|
||
with open(image_path, "rb") as image: | ||
response = ImageProccesing("rode").process_file(image, version) | ||
|
||
#change names to spanish | ||
response['data'][0]['name'] = "rotado" if response['data'][0]['name'] == "rotated" else "no rotado" | ||
|
||
st.caption(f"Pagina {i + 1} del PDF {name}") | ||
|
||
data = { | ||
"archivo": [name], | ||
"pagina": [f'Page {i + 1}'], # "Page 1 | ||
"predicción": [response['data'][0]['name']], | ||
"confianza": [response['data'][0]['confidence'] * 100], | ||
"tiempo(s)": [response['time']], | ||
"fecha": [datetime.now().strftime("%Y-%m-%d %H:%M:%S")] | ||
} | ||
|
||
return data, response, image_path, name_file_rand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .display_metrics import single_model_metrics | ||
from .process_files import ImageProccesing | ||
from .filters import hoja_control | ||
from .filters import hoja_control | ||
from .RoDeProc import procces_image_rode, procces_pdf2image_rode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters