ppryan commited on
Commit
31c8877
·
verified ·
1 Parent(s): bcd23f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -1,13 +1,30 @@
1
  from pathlib import Path
2
  import sys
 
3
 
4
  import gradio as gr
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  sys.path.insert(0, str(Path(__file__).resolve().parent / "src"))
7
 
8
  from multilingual_sentiment_analysis.infer import predict, predict_batch
9
 
10
 
 
11
  def analyze_single(text: str):
12
  if not text or not text.strip():
13
  return "⚠️ Please enter some text", ""
 
1
  from pathlib import Path
2
  import sys
3
+ from types import SimpleNamespace
4
 
5
  import gradio as gr
6
 
7
+ try:
8
+ import spaces
9
+ except ImportError:
10
+ def _gpu_decorator(fn=None, *args, **kwargs):
11
+ def decorator(func):
12
+ return func
13
+
14
+ if fn is None:
15
+ return decorator
16
+ if callable(fn):
17
+ return fn
18
+ return decorator
19
+
20
+ spaces = SimpleNamespace(GPU=_gpu_decorator)
21
+
22
  sys.path.insert(0, str(Path(__file__).resolve().parent / "src"))
23
 
24
  from multilingual_sentiment_analysis.infer import predict, predict_batch
25
 
26
 
27
+ @spaces.GPU
28
  def analyze_single(text: str):
29
  if not text or not text.strip():
30
  return "⚠️ Please enter some text", ""