Spaces:
Running
on
Zero
Running
on
Zero
StevenChen16
commited on
Commit
•
3fe030d
1
Parent(s):
ec2678b
Update app.py
Browse files
app.py
CHANGED
@@ -2,12 +2,14 @@ import gradio as gr
|
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
3 |
import torch
|
4 |
import re
|
|
|
5 |
|
6 |
def split_into_sentences(text):
|
7 |
sentence_endings = re.compile(r'(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?|\!)\s')
|
8 |
sentences = sentence_endings.split(text)
|
9 |
return [sentence.strip() for sentence in sentences if sentence]
|
10 |
|
|
|
11 |
def process_paragraph(paragraph, progress=gr.Progress()):
|
12 |
sentences = split_into_sentences(paragraph)
|
13 |
results = []
|
|
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
3 |
import torch
|
4 |
import re
|
5 |
+
import spaces
|
6 |
|
7 |
def split_into_sentences(text):
|
8 |
sentence_endings = re.compile(r'(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?|\!)\s')
|
9 |
sentences = sentence_endings.split(text)
|
10 |
return [sentence.strip() for sentence in sentences if sentence]
|
11 |
|
12 |
+
@spaces.GPU
|
13 |
def process_paragraph(paragraph, progress=gr.Progress()):
|
14 |
sentences = split_into_sentences(paragraph)
|
15 |
results = []
|