Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -125,9 +125,7 @@ def predict_2(txt_url, normalized_content_with_style):
|
|
125 |
confidence_scores_content,
|
126 |
new_data,
|
127 |
) = (None, None, None, None, None)
|
128 |
-
|
129 |
predicted_label_text, confidence_score_text = None, None
|
130 |
-
|
131 |
if txt_url.startswith("http://") or txt_url.startswith("https://"):
|
132 |
(
|
133 |
predicted_label_title,
|
@@ -147,7 +145,6 @@ def predict_2(txt_url, normalized_content_with_style):
|
|
147 |
max_length=512,
|
148 |
return_tensors="pt",
|
149 |
)
|
150 |
-
|
151 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
152 |
test_input_ids = test_encodings["input_ids"].to(device)
|
153 |
test_attention_mask = test_encodings["attention_mask"].to(device)
|
@@ -172,7 +169,6 @@ def predict_2(txt_url, normalized_content_with_style):
|
|
172 |
confidence_score_text,
|
173 |
#new,
|
174 |
)
|
175 |
-
|
176 |
def word_by_word(txt_url, normalized_content_with_style):
|
177 |
if txt_url.startswith("http://") or txt_url.startswith("https://") or txt_url.startswith(""):
|
178 |
(
|
@@ -235,8 +231,6 @@ def word_by_word(txt_url, normalized_content_with_style):
|
|
235 |
confidence_score_text,
|
236 |
new_word,
|
237 |
)
|
238 |
-
|
239 |
-
|
240 |
demo = gr.Interface(
|
241 |
fn=word_by_word,
|
242 |
inputs=[
|
@@ -254,5 +248,4 @@ demo = gr.Interface(
|
|
254 |
gr.outputs.Textbox(label="word-by-word").style(show_copy_button=True),
|
255 |
],
|
256 |
)
|
257 |
-
|
258 |
demo.launch()
|
|
|
125 |
confidence_scores_content,
|
126 |
new_data,
|
127 |
) = (None, None, None, None, None)
|
|
|
128 |
predicted_label_text, confidence_score_text = None, None
|
|
|
129 |
if txt_url.startswith("http://") or txt_url.startswith("https://"):
|
130 |
(
|
131 |
predicted_label_title,
|
|
|
145 |
max_length=512,
|
146 |
return_tensors="pt",
|
147 |
)
|
|
|
148 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
149 |
test_input_ids = test_encodings["input_ids"].to(device)
|
150 |
test_attention_mask = test_encodings["attention_mask"].to(device)
|
|
|
169 |
confidence_score_text,
|
170 |
#new,
|
171 |
)
|
|
|
172 |
def word_by_word(txt_url, normalized_content_with_style):
|
173 |
if txt_url.startswith("http://") or txt_url.startswith("https://") or txt_url.startswith(""):
|
174 |
(
|
|
|
231 |
confidence_score_text,
|
232 |
new_word,
|
233 |
)
|
|
|
|
|
234 |
demo = gr.Interface(
|
235 |
fn=word_by_word,
|
236 |
inputs=[
|
|
|
248 |
gr.outputs.Textbox(label="word-by-word").style(show_copy_button=True),
|
249 |
],
|
250 |
)
|
|
|
251 |
demo.launch()
|