File size: 653 Bytes
fbe515e
 
 
 
28d5b3d
 
fbe515e
 
 
28d5b3d
 
 
0e83192
b6a95e0
663083f
b6a95e0
fbe515e
 
663083f
fbe515e
b6a95e0
 
 
28d5b3d
 
 
 
 
6d15033
28d5b3d
 
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
import numpy as np
import seaborn as sns
import matplotlib
import matplotlib.pyplot as plt
from plt_id import generate_image_key
import os

matplotlib.use("Agg")

UPLOAD_FOLDER = "/plots"


def plot(model) -> None:
    sns.set()
    fig, ax = plt.subplots()
    sns.lineplot(
        x=np.arange(len(model.loss_history)),
        y=model.loss_history,
        ax=ax,
    )
    plt.ylabel("Loss")
    plt.xlabel("Epoch")
    plt.title("Loss / Epoch")

    image_key = generate_image_key()

    plot_filename = os.path.join(UPLOAD_FOLDER, f"{image_key}.png")
    fig.savefig(plot_filename, format="png")
    plt.close(fig)

    model.plot_key = image_key