-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
52 lines (41 loc) · 1.56 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os
import streamlit as st
from core import Extractor
from detector import detect_text
from PIL import Image
def main():
st.title('Extrator de placas veiculares')
st.markdown("""
### Instruções
Faça o upload de uma imagem e clique em **processar**.
Nós tentaremos extrair **somente** a placa. (utilizaremos como base o padrão mercosul)
""")
st.info('Para um melhor resultado, recomendamos enviar imagens em alta resolução')
image_file = st.file_uploader("Envie a imagem", type=['png', 'jpg', 'jpeg'])
if image_file:
image = Image.open(image_file)
if st.button("Processar"):
extractor = Extractor(image)
extracted = extractor()
if extracted is not None:
st.text("Placa extraída da imagem:")
st.image(extracted)
else:
st.error('Não conseguimos extrair a placa')
# if st.button('Detectar texto'):
# extractor = Extractor(image)
# extracted = extractor()
# try:
# if extracted is None:
# raise Exception("Não conseguimos extrair nenhuma placa")
#
# st.text("Placa extraída da imagem:")
# st.image(extracted)
# text = detect_text(extracted)
# st.success(f'Texto extraído: {text}')
# except Exception as exc:
# st.error(str(exc))
else:
st.text('Faça o upload de uma imagem')
if __name__ == '__main__':
main()