Based on ShikjarDua's approach, I created a version which works independent of tick positions. This comes in handy when dealing with grouped data in seaborn (i.e. hue=parameter). Additionally, I added a "flier-detection", which changes the lines per drawn box.

import seaborn as sns
import matplotlib.pyplot as plt
import matplotlib.patheffects as path_effects
def add_median_labels(ax):
lines = ax.get_lines()
# determine number of lines per box (this varies with/without fliers)
boxes = [c for c in ax.get_children() if type(c).__name__ == 'PathPatch']
lines_per_box = int(len(lines) / len(boxes))
# iterate over median lines
for median in lines[4:len(lines):lines_per_box]:
# display median value at center of median line
x, y = (data.mean() for data in median.get_data())
# choose value depending on horizontal or vertical plot orientation
value = x if (median.get_xdata()[1]-median.get_xdata()[0]) == 0 else y
text = ax.text(x, y, f'{value:.1f}', ha='center', va='center',
fontweight='bold', color='white')
# create median-colored border around white text for contrast
text.set_path_effects([
path_effects.Stroke(linewidth=3, foreground=median.get_color()),
path_effects.Normal(),
])
sns.set_style("darkgrid")
tips = sns.load_dataset("tips")
box_plot = sns.boxplot(x="day", y="total_bill", data=tips, showfliers=False, hue="sex")
add_median_labels(box_plot.axes)
plt.show()