czyoung commited on
Commit
a0c97db
·
verified ·
1 Parent(s): 7f24f7f

Added loading of pretrained model

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py CHANGED
@@ -16,6 +16,10 @@ import streamlit as st
16
  import torch
17
  import pandas as pd
18
  from pyannote.audio import Pipeline
 
 
 
 
19
 
20
  import sonogram_utility as su
21
  import utils
@@ -71,7 +75,24 @@ if ENABLE_DENOISE:
71
  else:
72
  dfModel = dfState = None
73
 
 
74
  pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  pipeline.to(device)
76
 
77
  # ---------------------------------------------------------------------------
 
16
  import torch
17
  import pandas as pd
18
  from pyannote.audio import Pipeline
19
+ from pyannote.audio.pipelines import SpeakerDiarization
20
+ from pyannote.audio.models.segmentation import PyanNet
21
+ from pyannote.audio import Inference
22
+ from pyannote.pipeline.parameter import ParamDict
23
 
24
  import sonogram_utility as su
25
  import utils
 
75
  else:
76
  dfModel = dfState = None
77
 
78
+ # Load baseline model
79
  pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1")
80
+
81
+ # Generate replacement segmentation model
82
+ newSpecs = pipeline._segmentation.model.specifications
83
+ segModel = PyanNet.from_pretrained('20251208_Sonogram_Segmentation.ckpt')
84
+ segModel.specifications = newSpecs
85
+ segmentation_duration = segModel.specifications.duration
86
+
87
+ # Update baseline with training
88
+ pipeline._segmentation = Inference(
89
+ segModel,
90
+ duration=segmentation_duration,
91
+ step=pipeline.segmentation_step * segmentation_duration,
92
+ skip_aggregation=True,
93
+ batch_size=1,
94
+ )
95
+
96
  pipeline.to(device)
97
 
98
  # ---------------------------------------------------------------------------