Spaces:
AIR-Bench
/
Running on CPU Upgrade

hanhainebula commited on
Commit
d940579
·
1 Parent(s): ee29a0c

fix: add HfFolder shim for huggingface-hub >=1.0 compatibility with gradio 4.29.0

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py CHANGED
@@ -26,6 +26,30 @@ except ModuleNotFoundError:
26
  _audioop.error = Exception
27
  sys.modules["audioop"] = _audioop
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  import os
30
 
31
  import gradio as gr
 
26
  _audioop.error = Exception
27
  sys.modules["audioop"] = _audioop
28
 
29
+ # huggingface_hub >= 1.0 removed HfFolder (gradio 4.29.0 oauth.py imports it)
30
+ import huggingface_hub
31
+
32
+ if not hasattr(huggingface_hub, "HfFolder"):
33
+
34
+ class _HfFolder:
35
+ path = "/root/.huggingface/token"
36
+
37
+ @staticmethod
38
+ def get_token():
39
+ import os as _os
40
+
41
+ return _os.environ.get("HF_TOKEN")
42
+
43
+ @staticmethod
44
+ def save_token(token):
45
+ pass
46
+
47
+ @staticmethod
48
+ def delete_token():
49
+ pass
50
+
51
+ huggingface_hub.HfFolder = _HfFolder
52
+
53
  import os
54
 
55
  import gradio as gr