Spaces:
Running
Running
Commit
Β·
b2a109a
1
Parent(s):
6f4f68c
Update app.py
Browse files
app.py
CHANGED
@@ -107,10 +107,23 @@ iface = gr.TabbedInterface([iface_sentence, iface_dataset], ["Sentence", "Datase
|
|
107 |
iface.queue().launch()
|
108 |
"""
|
109 |
|
|
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
def inference_sentence(text):
|
112 |
output = "This sentence will be processed:\n" + text
|
113 |
return output
|
|
|
114 |
|
115 |
def unavailable(input_file, input_checks):
|
116 |
output = "Submitting your own data is currently unavailable, but you can try out the showcase mode π"
|
|
|
107 |
iface.queue().launch()
|
108 |
"""
|
109 |
|
110 |
+
inference_modelpath = "model/checkpoint-128"
|
111 |
|
112 |
+
def inference_sentence(text):
|
113 |
+
tokenizer = AutoTokenizer.from_pretrained(inference_modelpath)
|
114 |
+
model = AutoModelForSequenceClassification.from_pretrained(inference_modelpath)
|
115 |
+
for text in tqdm([text]):
|
116 |
+
inputs = tokenizer(text, return_tensors="pt")
|
117 |
+
with torch.no_grad(): # run model
|
118 |
+
logits = model(**inputs).logits
|
119 |
+
predicted_class_id = logits.argmax().item()
|
120 |
+
output = model.config.id2label[predicted_class_id]
|
121 |
+
return output
|
122 |
+
"""
|
123 |
def inference_sentence(text):
|
124 |
output = "This sentence will be processed:\n" + text
|
125 |
return output
|
126 |
+
"""
|
127 |
|
128 |
def unavailable(input_file, input_checks):
|
129 |
output = "Submitting your own data is currently unavailable, but you can try out the showcase mode π"
|