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

Commit

Permalink
Merge pull request #6 from prefeitura-rio/new-api
Browse files Browse the repository at this point in the history
chore: sequencial imagens and skip if image_condition is poor
  • Loading branch information
d116626 authored Feb 7, 2024
2 parents ab6c1fe + 66c9710 commit 677d60f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
10 changes: 8 additions & 2 deletions app/Home.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@

import streamlit as st
from streamlit_folium import st_folium # noqa
from utils.utils import (create_map, display_camera_details, get_agrid_table,
get_cameras, get_filted_cameras_objects, treat_data)
from utils.utils import (
create_map,
display_camera_details,
get_agrid_table,
get_cameras,
get_filted_cameras_objects,
treat_data,
)

st.set_page_config(layout="wide", initial_sidebar_state="collapsed")
# st.image("./data/logo/logo.png", width=300)
Expand Down
14 changes: 5 additions & 9 deletions app/pages/Classificador de Labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ def get_translation(label):
return translation


#

snapshots_identifications = [
{
"object": "image_condition",
Expand Down Expand Up @@ -105,16 +103,17 @@ def get_translation(label):
snapshots_objects = explode_df(
pd.DataFrame(data=snapshots), "snapshot_identification"
) # noqa
# randomize dataframe
snapshots_objects = snapshots_objects.sample(frac=1)


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"
): # noqa
st.session_state.row_index += 3

print(json.dumps(snapshots_to_put, indent=4), "\n")


Expand Down Expand Up @@ -183,16 +182,13 @@ def buttom(
st.image(snapshot_url)
st.markdown(
f"### {translate_dict.get('title')}",
unsafe_allow_html=True,
)
st.markdown(
f"**Explicação:** {translate_dict.get('explanation')}",
unsafe_allow_html=True,
)
# place labels in a grid of 2 columns
col1, col2, col3, col4, col5, col6 = st.columns(6)
for i, label in enumerate(choices):
print(i, label)
label_translated = translate_dict.get("labels").get(label)

if i % 2 == 0:
Expand Down
9 changes: 6 additions & 3 deletions app/utils/utils.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# -*- coding: utf-8 -*-
import json # noqa
import os
import os # noqa
from typing import Union

import folium
import pandas as pd
import streamlit as st
from st_aggrid import (AgGrid, ColumnsAutoSizeMode, GridOptionsBuilder,
GridUpdateMode)
from st_aggrid import AgGrid, ColumnsAutoSizeMode, GridOptionsBuilder, GridUpdateMode
from utils.api import APIVisionAI


Expand Down Expand Up @@ -49,6 +48,10 @@ def callback_data():


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


@st.cache_data(ttl=600 * 2, persist=False)
Expand Down

0 comments on commit 677d60f

Please sign in to comment.