harp-dev commited on
Commit
b433e4a
·
verified ·
1 Parent(s): 725b706

Locate the bundled weights without pkg_resources, which setuptools dropped

Browse files
Files changed (2) hide show
  1. app.py +6 -3
  2. requirements.txt +0 -3
app.py CHANGED
@@ -8,7 +8,10 @@ import librosa
8
  import tempfile
9
  import os
10
 
11
- import pkg_resources
 
 
 
12
  import moduleconf
13
 
14
  from pyharp.core import ModelCard, build_endpoint
@@ -29,8 +32,8 @@ model_card = ModelCard(
29
 
30
  @lru_cache(maxsize=2)
31
  def load_model(device: str):
32
- defaultWeight = (pkg_resources.resource_filename("transkun", "pretrained/2.0.pt"))
33
- defaultConf = (pkg_resources.resource_filename("transkun", "pretrained/2.0.conf"))
34
 
35
  confManager = moduleconf.parseFromFile(defaultConf)
36
  conf = confManager["Model"].config
 
8
  import tempfile
9
  import os
10
 
11
+ # setuptools dropped this module in version 81, and it is only needed here
12
+ # to locate data files inside the installed transkun package, which
13
+ # importlib.resources does from the standard library.
14
+ from importlib.resources import files
15
  import moduleconf
16
 
17
  from pyharp.core import ModelCard, build_endpoint
 
32
 
33
  @lru_cache(maxsize=2)
34
  def load_model(device: str):
35
+ defaultWeight = str(files("transkun") / "pretrained" / "2.0.pt")
36
+ defaultConf = str(files("transkun") / "pretrained" / "2.0.conf")
37
 
38
  confManager = moduleconf.parseFromFile(defaultConf)
39
  conf = confManager["Model"].config
requirements.txt CHANGED
@@ -5,6 +5,3 @@ git+https://github.com/TEAMuP-dev/pyharp.git@v0.4.1
5
  transkun
6
  librosa
7
  spaces>=0.51.1
8
- # app.py imports pkg_resources, which setuptools provides and which is no
9
- # longer installed by default from Python 3.12 on.
10
- setuptools
 
5
  transkun
6
  librosa
7
  spaces>=0.51.1