Opsifiz commited on
Commit
aca8cba
·
1 Parent(s): 40996b4

Edit app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -21,14 +21,6 @@ id2label = {
21
  6: 'schizophrenia'
22
  }
23
 
24
- # Inference function
25
- def predict(text):
26
- inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
27
- with torch.no_grad():
28
- outputs = model(**inputs)
29
- pred_id = outputs.logits.argmax(dim=1).item()
30
- return id2label[pred_id]
31
-
32
  def clean_text(text):
33
  text = str(text)
34
  text = text.lower()
@@ -39,6 +31,15 @@ def clean_text(text):
39
  text = re.sub(r'\s+', ' ', text).strip()
40
  return text
41
 
 
 
 
 
 
 
 
 
 
42
  # Gradio UI
43
  demo = gr.Interface(
44
  fn=predict,
 
21
  6: 'schizophrenia'
22
  }
23
 
 
 
 
 
 
 
 
 
24
  def clean_text(text):
25
  text = str(text)
26
  text = text.lower()
 
31
  text = re.sub(r'\s+', ' ', text).strip()
32
  return text
33
 
34
+ # Inference function
35
+ def predict(text):
36
+ text = clean_text(text)
37
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
38
+ with torch.no_grad():
39
+ outputs = model(**inputs)
40
+ pred_id = outputs.logits.argmax(dim=1).item()
41
+ return id2label[pred_id]
42
+
43
  # Gradio UI
44
  demo = gr.Interface(
45
  fn=predict,