ravids commited on
Commit ·
a19f717
1
Parent(s): 7eb626d
Update code
Browse files- app.py +14 -1
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -13,7 +13,19 @@ import urllib.error
|
|
| 13 |
import urllib.parse
|
| 14 |
import urllib.request
|
| 15 |
|
| 16 |
-
import spaces
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
import torch
|
| 18 |
|
| 19 |
import granite_switch.hf # noqa: F401 — registers HF backend
|
|
@@ -791,6 +803,7 @@ with gr.Blocks(title="Granite Switch 4.1 3B Playground") as demo:
|
|
| 791 |
outputs=ca_output,
|
| 792 |
)
|
| 793 |
|
|
|
|
| 794 |
#if __name__ == "__main__":
|
| 795 |
# demo.launch()
|
| 796 |
|
|
|
|
| 13 |
import urllib.parse
|
| 14 |
import urllib.request
|
| 15 |
|
| 16 |
+
# Ravid old use import spaces
|
| 17 |
+
try:
|
| 18 |
+
import spaces
|
| 19 |
+
except ImportError:
|
| 20 |
+
class _SpacesFallback:
|
| 21 |
+
@staticmethod
|
| 22 |
+
def GPU(fn=None, **kwargs):
|
| 23 |
+
if fn is None:
|
| 24 |
+
return lambda wrapped: wrapped
|
| 25 |
+
return fn
|
| 26 |
+
|
| 27 |
+
spaces = _SpacesFallback()
|
| 28 |
+
|
| 29 |
import torch
|
| 30 |
|
| 31 |
import granite_switch.hf # noqa: F401 — registers HF backend
|
|
|
|
| 803 |
outputs=ca_output,
|
| 804 |
)
|
| 805 |
|
| 806 |
+
# Ravid old use
|
| 807 |
#if __name__ == "__main__":
|
| 808 |
# demo.launch()
|
| 809 |
|
requirements.txt
CHANGED
|
@@ -8,3 +8,4 @@ transformers
|
|
| 8 |
accelerate
|
| 9 |
granite-switch[hf] @ git+https://github.com/generative-computing/granite-switch.git
|
| 10 |
gradio
|
|
|
|
|
|
| 8 |
accelerate
|
| 9 |
granite-switch[hf] @ git+https://github.com/generative-computing/granite-switch.git
|
| 10 |
gradio
|
| 11 |
+
spaces
|