Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
feat: asmall fix for new objects and labels
Browse files Browse the repository at this point in the history
  • Loading branch information
d116626 committed Feb 10, 2024
1 parent 57e9442 commit 26b1b2f
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 35 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Data files ignore rules are on data/.gitignore
**/**/test.py
test.py

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
46 changes: 25 additions & 21 deletions app/pages/Classificador de Labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@

import pandas as pd
import streamlit as st
from utils.utils import explode_df, get_objects, get_objetcs_labels_df
from utils.utils import explode_df, get_objects_cache, get_objetcs_labels_df

st.set_page_config(layout="wide", initial_sidebar_state="collapsed")
# st.image("./data/logo/logo.png", width=300)

st.markdown("# Classificador de labels | Vision AI")

objects = pd.DataFrame(get_objects())
objects = pd.DataFrame(get_objects_cache())

labels = get_objetcs_labels_df(objects)
labels.index = labels["name"]
labels = labels.drop(columns=["name"])
# labels.index = labels["name"]
# labels = labels.drop(columns=["name"])


# https://docs.google.com/document/d/1PRCjbIJw4_g3-p4gLjYoN0qTaenephyZyOsiOfVGWzM/edit
Expand All @@ -23,17 +23,17 @@
def get_translation(label):
markdown_translation = [
{
"object": "image_condition",
"title": "A imagem está nítida?",
"condition": "Se a resposta for 'Não', pule para a próxima imagem.", # noqa
"object": "image_corrupted",
"title": "A imagem está corrompida?",
"condition": "Se a resposta for 'Sim', pule para a próxima imagem.", # noqa
"explanation": "Confira se os detalhes na imagem estão claros e definidos. Uma imagem considerada nítida permite a identificação dos objetos e do cenário.", # noqa
"labels": {
"clean": "Sim",
"poor": "Não",
"true": "Sim",
"false": "Não",
},
},
{
"object": "water_in_road",
"object": "rain",
"title": "Há indício de chuva?",
"condition": "Se a resposta for 'Não', associe o rótulo ‘Baixa ou Indiferente’ à opção 3 e pule para 4.", # noqa
"explanation": " Inspeção visual para presença de água na pista, que pode variar desde uma leve umidade até condições de alagamento evidente.", # noqa
Expand All @@ -48,9 +48,9 @@ def get_translation(label):
"condition": "Se a resposta for 'Não', pule para a próxima imagem.", # noqa
"explanation": "Estime o volume de água presente na pista, categorizando-o como um muito baixa (menos que ¼ da roda de um veículo de passeio), bolsão (entre ¼ e ½ da roda), ou alagamento (mais que ½ da roda).", # noqa
"labels": {
"low_indifferent": "Baixa ou Indiferente",
"puddle": "Bolsão d'água",
"flodding": "Alagamento",
"low": "Baixa ou Indiferente",
"medium": "Bolsão d'água",
"high": "Alagamento",
},
},
{
Expand All @@ -60,8 +60,8 @@ def get_translation(label):
"explanation": "Avalie se há algum obstáculo na via que impeça a circulação de veículos. O obstáculo pode ser um acúmulo de água, árvore caída, carro enguiçado, entre outros.", # noqa
"labels": {
"free": "Sem obstáculos",
"partially_blocked": "Via parcialmente bloqueada",
"totally_blocked": "Via bloqueada",
"partially": "Via parcialmente bloqueada",
"totally": "Via bloqueada",
},
},
]
Expand All @@ -73,11 +73,11 @@ def get_translation(label):

snapshots_identifications = [
{
"object": "image_condition",
"object": "image_corrupted",
"label": "none",
},
{
"object": "water_in_road",
"object": "rain",
"label": "none",
},
{
Expand Down Expand Up @@ -110,16 +110,19 @@ def get_translation(label):
snapshots_objects["object"].unique().tolist()
) # noqa
}
snapshots_objects["question_number"] = snapshots_objects["object"].map(objects_number)
snapshots_objects["question_number"] = snapshots_objects["object"].map(
objects_number
) # noqa


def put_selected_label(label, snapshots_options):
snapshots_to_put = snapshots_options.to_dict()
snapshots_to_put["label"] = label
# # TODO: make a put for selected object/label
if (snapshots_to_put.get("object") == "image_condition") and (
label == "poor"
if (snapshots_to_put.get("object") == "image_corrupted") and (
label == "true"
): # noqa
print("HEREEE")
st.session_state.row_index += 3

print(json.dumps(snapshots_to_put, indent=4), "\n")
Expand Down Expand Up @@ -175,10 +178,11 @@ def buttom(
translate_dict = get_translation(name)
snapshot_url = row["snapshot_url"]
question_number = row["question_number"]
labels_options = labels[labels["name"] == name]

labels_options = labels.loc[name]
choices = labels_options["value"].tolist()
choices.sort()

if "true" in choices:
choices = ["true", "false"]

Expand Down
31 changes: 19 additions & 12 deletions app/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
import numpy as np
import pandas as pd
import streamlit as st
from st_aggrid import (
AgGrid,
ColumnsAutoSizeMode,
GridOptionsBuilder,
GridUpdateMode,
)
from st_aggrid import GridOptionsBuilder # noqa
from st_aggrid import GridUpdateMode # noqa
from st_aggrid import AgGrid, ColumnsAutoSizeMode # noqa
from utils.api import APIVisionAI


Expand Down Expand Up @@ -53,11 +50,11 @@ def callback_data():
return vision_api


vision_api = get_vision_ai_api()
# vision_api = APIVisionAI(
# username=os.environ.get("VISION_API_USERNAME"),
# password=os.environ.get("VISION_API_PASSWORD"),
# )
# vision_api = get_vision_ai_api()
vision_api = APIVisionAI(
username=os.environ.get("VISION_API_USERNAME"),
password=os.environ.get("VISION_API_PASSWORD"),
)


def get_cameras(
Expand Down Expand Up @@ -260,12 +257,21 @@ def get_icon_color(label: Union[bool, None], type=None):
"poor",
"true",
"flodding",
"high",
"totally",
]: # noqa
if type == "emoji":
return "🔴"
return "red"

elif label in ["minor", "partially_blocked", "difficult", "puddle"]:
elif label in [
"minor",
"partially_blocked",
"difficult",
"puddle",
"medium",
"partially",
]:
if type == "emoji":
return "🟠"
return "orange"
Expand All @@ -277,6 +283,7 @@ def get_icon_color(label: Union[bool, None], type=None):
"clean",
"false",
"low_indifferent",
"low",
]:
if type == "emoji":
return "🟢"
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ build-backend = "poetry.core.masonry.api"


[tool.flake8]
max-line-length = 80
max-line-length = 100
exclude = [".git", "__pycache__", "dist"]
max-complexity = 10

[tool.isort]
atomic = true
profile = "black"
line_length = 80
line_length = 100
skip_gitignore = true

0 comments on commit 26b1b2f

Please sign in to comment.