Spaces:
Running
Running
File size: 4,811 Bytes
f8bf7d4 |
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
import numpy as np
import pandas as pd
WHALE_CLASSES = np.array(
[
"beluga",
"blue_whale",
"bottlenose_dolphin",
"brydes_whale",
"commersons_dolphin",
"common_dolphin",
"cuviers_beaked_whale",
"dusky_dolphin",
"false_killer_whale",
"fin_whale",
"frasiers_dolphin",
"gray_whale",
"humpback_whale",
"killer_whale",
"long_finned_pilot_whale",
"melon_headed_whale",
"minke_whale",
"pantropic_spotted_dolphin",
"pygmy_killer_whale",
"rough_toothed_dolphin",
"sei_whale",
"short_finned_pilot_whale",
"southern_right_whale",
"spinner_dolphin",
"spotted_dolphin",
"white_sided_dolphin",
]
)
WHALE_IMAGES = np.array(
[
"beluga.webp",
"blue-whale.webp",
"bottlenose_dolphin.webp",
"brydes.webp",
"common_dolphin.webp",
"common_dolphin.webp",
"cuviers_beaked_whale.webp",
"common_dolphin.webp",
"false-killer-whale.webp",
"fin-whale.webp",
"fin-whale.webp",
"gray-whale.webp",
"Humpback.webp",
"killer_whale.webp",
"640x427-long-finned-pilot-whale.webp",
"melon.webp",
"minke-whale.webp",
"pantropic-spotted-dolphin.webp",
"pygmy-killer-whale.webp",
"rough-toothed-dolphin.webp",
"sei.webp",
"Whale_Short-Finned_Pilot-markedDW.png", ## Background
"640x427-southern-right-whale.jpg", ## background
"spinner.webp",
"pantropical-spotted-dolphin.webp", ## duplicate also used for
"640x427-atlantic-white-sided-dolphin.jpg", ##background
]
)
WHALE_REFERENCES = np.array(
[
"https://www.fisheries.noaa.gov/species/beluga-whale",
"https://www.fisheries.noaa.gov/species/blue-whale",
"https://www.fisheries.noaa.gov/species/common-bottlenose-dolphin",
"https://www.fisheries.noaa.gov/species/brydes-whale",
"commersons_dolphin - reference missing - classification to be verified", ## class matching to be verified
"https://www.fisheries.noaa.gov/species/short-beaked-common-dolphin",
"https://www.fisheries.noaa.gov/species/cuviers-beaked-whale",
"dusky_dolphin - reference missing - classification to be verified", ## class matching to be verified
"https://www.fisheries.noaa.gov/species/false-killer-whale",
"https://www.fisheries.noaa.gov/species/fin-whale",
"frasiers_dolphin - reference missing - classification to be verified", ## class matching to be verified
"https://www.fisheries.noaa.gov/species/gray-whale",
"https://www.fisheries.noaa.gov/species/humpback-whale",
"https://www.fisheries.noaa.gov/species/killer-whale",
"https://www.fisheries.noaa.gov/species/long-finned-pilot-whale",
"https://www.fisheries.noaa.gov/species/melon-headed-whale",
"https://www.fisheries.noaa.gov/species/minke-whale",
"https://www.fisheries.noaa.gov/species/pantropical-spotted-dolphin",
"https://www.fisheries.noaa.gov/species/pygmy-killer-whale",
"https://www.fisheries.noaa.gov/species/rough-toothed-dolphin",
"https://www.fisheries.noaa.gov/species/sei-whale",
"https://www.fisheries.noaa.gov/species/short-finned-pilot-whale",
"https://www.fisheries.noaa.gov/species/southern-right-whale",
"https://www.fisheries.noaa.gov/species/spinner-dolphin",
"https://www.fisheries.noaa.gov/species/pantropical-spotted-dolphin",
"https://www.fisheries.noaa.gov/species/atlantic-white-sided-dolphin",
]
)
# Create a dataframe
df_whale_img_ref = pd.DataFrame(
{
"WHALE_CLASSES": WHALE_CLASSES,
"WHALE_IMAGES": WHALE_IMAGES,
"WHALE_REFERENCES": WHALE_REFERENCES,
}
).set_index("WHALE_CLASSES")
import streamlit as st
from PIL import Image
## Replace this with model's output
whale_classes = ["blue_whale", "gray_whale", "spotted_dolphin"]
def format_whale_name(whale_class):
whale_name = whale_class.replace("_", " ").title()
return whale_name
def display_whale(whale_class, i):
st.markdown(
"## :whale: #" + str(i + 1) + ": " + format_whale_name(whale_classes[i])
)
image = Image.open("images/references/" + df_whale_img_ref.loc[whale_classes[i], "WHALE_IMAGES"])
st.image(image, caption=df_whale_img_ref.loc[whale_classes[i], "WHALE_REFERENCES"])
# link st.markdown(f"[{df.loc[whale_classes[i], 'WHALE_REFERENCES']}]({df.loc[whale_classes[i], 'WHALE_REFERENCES']})")
st.markdown("# Species detected (Cetacean Classifier):")
for i in range(len(whale_classes)):
display_whale(whale_classes[i], i)
|