Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import spaces
|
| 2 |
import gradio as gr
|
| 3 |
import torch
|
|
|
|
| 1 |
+
|
| 2 |
+
# Compatibility fix for ZeroGPU's Gradio + newer huggingface_hub
|
| 3 |
+
import huggingface_hub
|
| 4 |
+
|
| 5 |
+
if not hasattr(huggingface_hub, "HfFolder"):
|
| 6 |
+
class HfFolder:
|
| 7 |
+
@staticmethod
|
| 8 |
+
def get_token():
|
| 9 |
+
return huggingface_hub.get_token()
|
| 10 |
+
|
| 11 |
+
@staticmethod
|
| 12 |
+
def save_token(token):
|
| 13 |
+
return huggingface_hub.login(token=token)
|
| 14 |
+
|
| 15 |
+
@staticmethod
|
| 16 |
+
def delete_token():
|
| 17 |
+
try:
|
| 18 |
+
huggingface_hub.logout()
|
| 19 |
+
except Exception:
|
| 20 |
+
pass
|
| 21 |
+
|
| 22 |
+
huggingface_hub.HfFolder = HfFolder
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
# IMPORTANT: import spaces after the compatibility patch
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|
| 31 |
import spaces
|
| 32 |
import gradio as gr
|
| 33 |
import torch
|