SHK4K commited on
Commit
aab2a91
·
1 Parent(s): 4b2a98e

Fixed things

Browse files
Files changed (3) hide show
  1. app.py +8 -2
  2. requirements.txt +2 -0
  3. requirments.txt +0 -3
app.py CHANGED
@@ -1,13 +1,18 @@
 
 
1
  import gradio as gr
 
2
  from transformers import pipeline
3
 
 
4
  pipe = pipeline(
5
  "text-classification",
6
  model="SHK4K/suicide-roberta",
7
- top_k=None,
8
  )
9
 
10
 
 
11
  def is_safe(text):
12
  if not text or not text.strip():
13
  return {
@@ -19,6 +24,7 @@ def is_safe(text):
19
  text,
20
  truncation=True,
21
  max_length=512,
 
22
  )[0]
23
 
24
  return {
@@ -44,7 +50,7 @@ demo = gr.Interface(
44
  title="Suicide Risk Detector",
45
 
46
  description=(
47
- "A research model that detects potential "
48
  "suicide-risk signals in text. "
49
  "This is not a medical diagnosis."
50
  ),
 
1
+ import spaces
2
+
3
  import gradio as gr
4
+ import torch
5
  from transformers import pipeline
6
 
7
+
8
  pipe = pipeline(
9
  "text-classification",
10
  model="SHK4K/suicide-roberta",
11
+ device=0 if torch.cuda.is_available() else -1,
12
  )
13
 
14
 
15
+ @spaces.GPU
16
  def is_safe(text):
17
  if not text or not text.strip():
18
  return {
 
24
  text,
25
  truncation=True,
26
  max_length=512,
27
+ top_k=None,
28
  )[0]
29
 
30
  return {
 
50
  title="Suicide Risk Detector",
51
 
52
  description=(
53
+ "A research NLP model that detects potential "
54
  "suicide-risk signals in text. "
55
  "This is not a medical diagnosis."
56
  ),
requirements.txt CHANGED
@@ -1,3 +1,5 @@
1
  gradio
2
  transformers
3
  torch
 
 
 
1
  gradio
2
  transformers
3
  torch
4
+ spaces
5
+ sentencepiece
requirments.txt DELETED
@@ -1,3 +0,0 @@
1
- gradio
2
- transformers
3
- torch