mumbert commited on
Commit
55010b0
·
1 Parent(s): ace54df

app_dcase.py requirements.txt: go back to simple demo with CLAP twice, place dcase baseline in dedicated branch until installation is solved

Browse files
Files changed (2) hide show
  1. app_dcase.py +18 -34
  2. requirements.txt +0 -6
app_dcase.py CHANGED
@@ -1,40 +1,26 @@
1
 
2
- # import gradio as gr
3
- # from msclap import CLAP
4
-
5
- # clap_model = CLAP(version = 'clapcap', use_cuda=False)
6
-
7
- # def clap_inference(mic=None, file=None):
8
-
9
- # if mic is not None:
10
- # audio = mic
11
- # elif file is not None:
12
- # audio = file
13
- # else:
14
- # return "You must either provide a mic recording or a file"
15
 
16
- # # Generate captions for the recording
17
- # captions = clap_model.generate_caption([audio],
18
- # resample=True,
19
- # beam_size=5,
20
- # entry_length=67,
21
- # temperature=0.01)
22
 
23
- # return captions[0]
24
 
25
- from transformers import pipeline
26
- import gradio as gr
27
- import torchaudio
28
- import torch
29
- from dcase24t6.nn.hub import baseline_pipeline
30
- import os
31
- import gdown
32
 
33
- def download_dcase_model_checkpoint():
 
 
 
 
 
34
 
35
- url = "https://drive.google.com/uc?id=1JABWIBlHuLAhYPX5ktbyLniH-YpeRyeT"
36
- output = 'epoch_232-step_001864-mode_min-val_loss_3.3752.ckpt'
37
- gdown.download(url, output, quiet=False)
38
 
39
  def create_app():
40
 
@@ -45,7 +31,7 @@ def create_app():
45
  """
46
  )
47
  gr.Interface(
48
- fn=dcase_inference,
49
  inputs=[
50
  gr.Audio(sources="microphone", type="filepath"),
51
  gr.Audio(sources="upload", type="filepath"),
@@ -55,8 +41,6 @@ def create_app():
55
 
56
  return demo
57
 
58
- download_dcase_model_checkpoint()
59
-
60
  def main():
61
 
62
  app = create_app()
 
1
 
2
+ import gradio as gr
3
+ from msclap import CLAP
 
 
 
 
 
 
 
 
 
 
 
4
 
5
+ clap_model = CLAP(version = 'clapcap', use_cuda=False)
 
 
 
 
 
6
 
7
+ def clap_inference(mic=None, file=None):
8
 
9
+ if mic is not None:
10
+ audio = mic
11
+ elif file is not None:
12
+ audio = file
13
+ else:
14
+ return "You must either provide a mic recording or a file"
 
15
 
16
+ # Generate captions for the recording
17
+ captions = clap_model.generate_caption([audio],
18
+ resample=True,
19
+ beam_size=5,
20
+ entry_length=67,
21
+ temperature=0.01)
22
 
23
+ return captions[0]
 
 
24
 
25
  def create_app():
26
 
 
31
  """
32
  )
33
  gr.Interface(
34
+ fn=clap_inference,
35
  inputs=[
36
  gr.Audio(sources="microphone", type="filepath"),
37
  gr.Audio(sources="upload", type="filepath"),
 
41
 
42
  return demo
43
 
 
 
44
  def main():
45
 
46
  app = create_app()
requirements.txt CHANGED
@@ -1,8 +1,2 @@
1
  gradio==5.13.1
2
  msclap
3
- # transformers
4
- # torch==2.2.1
5
- # torchoutil[extras]~=0.3.0
6
- # ffmpeg
7
- # ffmpeg-python
8
- git+https://github.com/Labbeti/dcase2024-task6-baseline
 
1
  gradio==5.13.1
2
  msclap