Skip to content

Commit

Permalink
moving label dict to global for reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
rbedman committed Oct 4, 2024
1 parent bcaa13b commit 6e7d774
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions demo/scenarios/garden.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,8 @@

import pandas as pd


def load_base_results(data_folder: str) -> pd.DataFrame:
df_results = pd.read_csv(
path.join(data_folder, "FlowerModelv1_TestSetResults.csv")
)
df_results.drop(columns=["Unnamed: 0"], inplace=True)
return df_results


def load_taxonomy(data_folder: str) -> pd.DataFrame:
"""Loads taxonomy info about the flowers and returns a dict with it."""
df_labels = pd.read_csv(
path.join(data_folder, "OxfordFlowerLabels.csv"), header=1
)
df_labels.drop(columns=["Phylum", "Class"], inplace=True)
df_labels.rename(columns={"Phylum.1": "Phylum"}, inplace=True)
df_labels.drop([0], inplace=True)
# df_labels['Common Name'] = df_labels['Common Name'].str.strip()
df_labels["Label Name"] = df_labels["Common Name"].replace(
" ", "_", regex=True
)
df_labels.head()

# set up a data lavel dictionary to switch between data label number and english name
label_dict = {
# set up a data label dictionary to switch between data label number and english name
label_dict = {
0: "_mexican_aster",
1: "alpine_sea_holly",
2: "anthurium",
Expand Down Expand Up @@ -130,6 +107,30 @@ def load_taxonomy(data_folder: str) -> pd.DataFrame:
100: "windflower",
101: "yellow_iris",
}
def load_base_results(data_folder: str) -> pd.DataFrame:
df_results = pd.read_csv(
path.join(data_folder, "FlowerModelv1_TestSetResults.csv")
)
df_results.drop(columns=["Unnamed: 0"], inplace=True)
return df_results


def load_taxonomy(data_folder: str) -> pd.DataFrame:
"""Loads taxonomy info about the flowers and returns a dict with it."""
df_labels = pd.read_csv(
path.join(data_folder, "OxfordFlowerLabels.csv"), header=1
)
df_labels.drop(columns=["Phylum", "Class"], inplace=True)
df_labels.rename(columns={"Phylum.1": "Phylum"}, inplace=True)
df_labels.drop([0], inplace=True)
# df_labels['Common Name'] = df_labels['Common Name'].str.strip()
df_labels["Label Name"] = df_labels["Common Name"].replace(
" ", "_", regex=True
)
df_labels.head()



df_dict = pd.DataFrame.from_dict(
{"Label": list(label_dict), "Label Name": label_dict.values()}
)
Expand Down

0 comments on commit 6e7d774

Please sign in to comment.