mandipgoswami commited on
Commit
ee92f51
·
verified ·
1 Parent(s): 1c7d1c9

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. app.py +4 -6
  2. requirements.txt +5 -6
app.py CHANGED
@@ -16,11 +16,9 @@ _client_utils.get_type = _get_type_handle_bool
16
 
17
  import librosa
18
  import matplotlib
 
19
  import matplotlib.pyplot as plt
20
  import numpy as np
21
- from transformers import pipeline
22
-
23
- matplotlib.use("Agg") # Non-interactive backend
24
 
25
  # Dataset metadata
26
  DATASET_INFO = {
@@ -49,17 +47,17 @@ model = None
49
 
50
 
51
  def load_model():
52
- """Lazy load the audio classification model."""
53
  global model
54
  if model is None:
55
  try:
 
56
  model = pipeline(
57
  "audio-classification",
58
  model=MODEL_NAME,
59
  )
60
  except Exception as e:
61
- print(f"Warning: Could not load model {MODEL_NAME}: {e}")
62
- print("Using placeholder predictions for demo.")
63
  model = "placeholder"
64
  return model
65
 
 
16
 
17
  import librosa
18
  import matplotlib
19
+ matplotlib.use("Agg") # Non-interactive backend
20
  import matplotlib.pyplot as plt
21
  import numpy as np
 
 
 
22
 
23
  # Dataset metadata
24
  DATASET_INFO = {
 
47
 
48
 
49
  def load_model():
50
+ """Lazy load the audio classification model. Uses placeholder if transformers unavailable."""
51
  global model
52
  if model is None:
53
  try:
54
+ from transformers import pipeline
55
  model = pipeline(
56
  "audio-classification",
57
  model=MODEL_NAME,
58
  )
59
  except Exception as e:
60
+ print(f"Using placeholder predictions (no model): {e}")
 
61
  model = "placeholder"
62
  return model
63
 
requirements.txt CHANGED
@@ -1,6 +1,5 @@
1
- gradio==4.35.0
2
- librosa==0.10.2
3
- matplotlib==3.8.2
4
- numpy==1.26.4
5
- soundfile==0.12.1
6
- huggingface_hub==0.19.4
 
1
+ gradio>=4.35.0
2
+ librosa>=0.10.0
3
+ matplotlib>=3.7.0
4
+ numpy>=1.24.0
5
+ soundfile>=0.12.0