Instructions to use ekolasky/CustomLEDForResultsIdOnSeperatedSet with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ekolasky/CustomLEDForResultsIdOnSeperatedSet with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="ekolasky/CustomLEDForResultsIdOnSeperatedSet", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("ekolasky/CustomLEDForResultsIdOnSeperatedSet", trust_remote_code=True) model = AutoModel.from_pretrained("ekolasky/CustomLEDForResultsIdOnSeperatedSet", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
Update handler.py
Browse files- handler.py +8 -2
handler.py
CHANGED
|
@@ -52,8 +52,14 @@ class EndpointHandler():
|
|
| 52 |
result_array = []
|
| 53 |
if (indices_array):
|
| 54 |
for result_indices in indices_array:
|
| 55 |
-
text = self.tokenizer.decode(input_ids[result_indices[0]:result_indices[-1]])
|
| 56 |
-
indices = [offset_mapping[result_indices[0]][0], offset_mapping[result_indices[-1]][
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
if text != " " and text != "":
|
| 58 |
result_array.append({'text': text, 'indices': indices})
|
| 59 |
return result_array
|
|
|
|
| 52 |
result_array = []
|
| 53 |
if (indices_array):
|
| 54 |
for result_indices in indices_array:
|
| 55 |
+
text = self.tokenizer.decode(input_ids[result_indices[0]:result_indices[-1]])
|
| 56 |
+
indices = [offset_mapping[result_indices[0]][0], offset_mapping[result_indices[-1]][1]]
|
| 57 |
+
while True:
|
| 58 |
+
if text[0] == " ":
|
| 59 |
+
text = text[1:]
|
| 60 |
+
indices[0] += 1
|
| 61 |
+
else:
|
| 62 |
+
break
|
| 63 |
if text != " " and text != "":
|
| 64 |
result_array.append({'text': text, 'indices': indices})
|
| 65 |
return result_array
|