mirror of
https://github.com/macaodha/batdetect2.git
synced 2026-08-22 03:00:10 +02:00
Merge pull request #76 from macaodha/fix/dependencies-issues
build: trim default runtime dependencies
This commit is contained in:
commit
afafccc26d
@ -11,10 +11,9 @@ dependencies = [
|
|||||||
"deepmerge>=2.0",
|
"deepmerge>=2.0",
|
||||||
"hydra-core>=1.3.2",
|
"hydra-core>=1.3.2",
|
||||||
"librosa>=0.10.1",
|
"librosa>=0.10.1",
|
||||||
"lightning[extra]==2.5.0",
|
"lightning==2.5.0",
|
||||||
"loguru>=0.7.3",
|
"loguru>=0.7.3",
|
||||||
"matplotlib>=3.7.1",
|
"matplotlib>=3.7.1",
|
||||||
"netcdf4>=1.6.5",
|
|
||||||
"numpy>=1.23.5",
|
"numpy>=1.23.5",
|
||||||
"pandas>=1.5.3",
|
"pandas>=1.5.3",
|
||||||
"pydantic>=2.0.0",
|
"pydantic>=2.0.0",
|
||||||
@ -24,9 +23,10 @@ dependencies = [
|
|||||||
"seaborn>=0.13.2",
|
"seaborn>=0.13.2",
|
||||||
"soundevent[audio,geometry,plot]>=2.10.0",
|
"soundevent[audio,geometry,plot]>=2.10.0",
|
||||||
"soundfile>=0.12.1",
|
"soundfile>=0.12.1",
|
||||||
"tensorboard>=2.16.2",
|
"tabulate>=0.10.0",
|
||||||
"torch>=2.0.0",
|
"torch>=2.0.0",
|
||||||
"torchaudio>=2.0.0",
|
"torchaudio>=2.0.0",
|
||||||
|
"tqdm>=4.70.0",
|
||||||
"xarray>=2024.0.0",
|
"xarray>=2024.0.0",
|
||||||
]
|
]
|
||||||
requires-python = ">=3.10,<3.14"
|
requires-python = ">=3.10,<3.14"
|
||||||
@ -88,6 +88,7 @@ dev = [
|
|||||||
"deepdiff>=8.6.1",
|
"deepdiff>=8.6.1",
|
||||||
"pytest-xdist[psutil]>=3.8.0",
|
"pytest-xdist[psutil]>=3.8.0",
|
||||||
]
|
]
|
||||||
|
tensorboard = ["tensorboard>=2.16.2"]
|
||||||
dvclive = ["dvclive>=3.48.2"]
|
dvclive = ["dvclive>=3.48.2"]
|
||||||
mlflow = ["mlflow>=3.1.1"]
|
mlflow = ["mlflow>=3.1.1"]
|
||||||
gradio = [
|
gradio = [
|
||||||
|
|||||||
@ -201,7 +201,14 @@ def create_tensorboard_logger(
|
|||||||
experiment_name: str | None = None,
|
experiment_name: str | None = None,
|
||||||
run_name: str | None = None,
|
run_name: str | None = None,
|
||||||
) -> Logger:
|
) -> Logger:
|
||||||
from lightning.pytorch.loggers import TensorBoardLogger
|
try:
|
||||||
|
from lightning.pytorch.loggers import TensorBoardLogger
|
||||||
|
except ImportError as error:
|
||||||
|
raise ValueError(
|
||||||
|
"TensorBoard is not installed and cannot be used for logging. "
|
||||||
|
"Make sure you have it installed by running `pip install tensorboard` "
|
||||||
|
"or `uv add tensorboard`"
|
||||||
|
) from error
|
||||||
|
|
||||||
if log_dir is None:
|
if log_dir is None:
|
||||||
log_dir = Path(config.log_dir)
|
log_dir = Path(config.log_dir)
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Literal, Sequence
|
from typing import List, Literal, Sequence, TypedDict
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@ -26,6 +26,11 @@ class ParquetOutputConfig(BaseConfig):
|
|||||||
include_geometry: bool = True
|
include_geometry: bool = True
|
||||||
|
|
||||||
|
|
||||||
|
class ClipInfo(TypedDict):
|
||||||
|
clip: data.Clip
|
||||||
|
preds: list[Detection]
|
||||||
|
|
||||||
|
|
||||||
class ParquetFormatter(OutputFormatterProtocol[ClipDetections]):
|
class ParquetFormatter(OutputFormatterProtocol[ClipDetections]):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -120,7 +125,7 @@ class ParquetFormatter(OutputFormatterProtocol[ClipDetections]):
|
|||||||
else:
|
else:
|
||||||
df = pd.read_parquet(path)
|
df = pd.read_parquet(path)
|
||||||
|
|
||||||
predictions_by_clip = {}
|
predictions_by_clip: dict[UUID, ClipInfo] = {}
|
||||||
|
|
||||||
for _, row in df.iterrows():
|
for _, row in df.iterrows():
|
||||||
clip_uuid = row["clip_uuid"]
|
clip_uuid = row["clip_uuid"]
|
||||||
|
|||||||
@ -185,25 +185,25 @@ def plot_clip_evaluation(
|
|||||||
label="found GT",
|
label="found GT",
|
||||||
edgecolor=gt_color,
|
edgecolor=gt_color,
|
||||||
facecolor="none" if not fill else gt_color,
|
facecolor="none" if not fill else gt_color,
|
||||||
linestyle=gt_linestyle,
|
linestyle=gt_linestyle, # type: ignore
|
||||||
),
|
),
|
||||||
patches.Patch(
|
patches.Patch(
|
||||||
label="missed GT",
|
label="missed GT",
|
||||||
edgecolor=missed_gt_color,
|
edgecolor=missed_gt_color,
|
||||||
facecolor="none" if not fill else missed_gt_color,
|
facecolor="none" if not fill else missed_gt_color,
|
||||||
linestyle=missed_gt_linestyle,
|
linestyle=missed_gt_linestyle, # type: ignore
|
||||||
),
|
),
|
||||||
patches.Patch(
|
patches.Patch(
|
||||||
label="true Det",
|
label="true Det",
|
||||||
edgecolor=true_pred_color,
|
edgecolor=true_pred_color,
|
||||||
facecolor="none" if not fill else true_pred_color,
|
facecolor="none" if not fill else true_pred_color,
|
||||||
linestyle=true_pred_linestyle,
|
linestyle=true_pred_linestyle, # type: ignore
|
||||||
),
|
),
|
||||||
patches.Patch(
|
patches.Patch(
|
||||||
label="false Det",
|
label="false Det",
|
||||||
edgecolor=false_pred_color,
|
edgecolor=false_pred_color,
|
||||||
facecolor="none" if not fill else false_pred_color,
|
facecolor="none" if not fill else false_pred_color,
|
||||||
linestyle=false_pred_linestyle,
|
linestyle=false_pred_linestyle, # type: ignore
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
"""Plot heatmaps."""
|
"""Plot heatmaps."""
|
||||||
|
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import torch
|
import torch
|
||||||
from matplotlib import axes, patches
|
from matplotlib import axes, patches
|
||||||
from matplotlib.cm import get_cmap
|
|
||||||
from matplotlib.colors import Colormap, LinearSegmentedColormap, to_rgba
|
from matplotlib.colors import Colormap, LinearSegmentedColormap, to_rgba
|
||||||
|
|
||||||
from batdetect2.plotting.common import create_ax
|
from batdetect2.plotting.common import create_ax
|
||||||
@ -80,7 +80,7 @@ def plot_classification_heatmap(
|
|||||||
raise ValueError("Inconsistent number of class names")
|
raise ValueError("Inconsistent number of class names")
|
||||||
|
|
||||||
if not isinstance(cmap, Colormap):
|
if not isinstance(cmap, Colormap):
|
||||||
cmap = get_cmap(cmap)
|
cmap = plt.get_cmap(cmap)
|
||||||
|
|
||||||
handles = []
|
handles = []
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user