Sompote commited on
Commit
694b174
·
verified ·
1 Parent(s): c627a78

Upload 12 files

Browse files
.claude/settings.local.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(python *)"
5
+ ]
6
+ }
7
+ }
__pycache__/app.cpython-311.pyc CHANGED
Binary files a/__pycache__/app.cpython-311.pyc and b/__pycache__/app.cpython-311.pyc differ
 
app.py CHANGED
@@ -8,6 +8,11 @@ for every prediction.
8
 
9
  from pathlib import Path
10
 
 
 
 
 
 
11
  import gradio as gr
12
  import matplotlib
13
  matplotlib.use("Agg")
@@ -83,6 +88,14 @@ def shap_figure(sv_ac, sv_sg, pred):
83
  return fig
84
 
85
 
 
 
 
 
 
 
 
 
86
  def predict(d0, d200, d300, d450, d600, d900, d1200, d1500, d1800,
87
  h_ac, h_base, h_subbase, explain):
88
  d = [d0, d200, d300, d450, d600, d900, d1200, d1500, d1800]
 
8
 
9
  from pathlib import Path
10
 
11
+ try:
12
+ import spaces # ZeroGPU: must be imported before torch
13
+ except ImportError: # local run / CPU Space without the spaces package
14
+ spaces = None
15
+
16
  import gradio as gr
17
  import matplotlib
18
  matplotlib.use("Agg")
 
88
  return fig
89
 
90
 
91
+ def _gpu(fn):
92
+ """ZeroGPU hardware refuses to start without a @spaces.GPU function.
93
+ Inference itself runs on CPU in <1 s (SHAP ~3 s), so the short duration
94
+ just satisfies the check while keeping queue priority high."""
95
+ return spaces.GPU(duration=30)(fn) if spaces is not None else fn
96
+
97
+
98
+ @_gpu
99
  def predict(d0, d200, d300, d450, d600, d900, d1200, d1500, d1800,
100
  h_ac, h_base, h_subbase, explain):
101
  d = [d0, d200, d300, d450, d600, d900, d1200, d1500, d1800]
requirements.txt CHANGED
@@ -1,4 +1,3 @@
1
- --extra-index-url https://download.pytorch.org/whl/cpu
2
  torch>=2.2
3
  numpy>=1.24
4
  shap>=0.45
 
 
1
  torch>=2.2
2
  numpy>=1.24
3
  shap>=0.45