sabarinathan commited on
Commit
a3b58ed
·
verified ·
1 Parent(s): 2f10d6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -1,9 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Created on Tue Sep 17 20:56:04 2024
4
 
5
- @author: SABARI
6
- """
7
  # -*- coding: utf-8 -*-
8
  """
9
  Created on Tue Sep 17 19:03:17 2024
@@ -58,7 +53,8 @@ class JapaneseNER():
58
  sample_encoding = self.tokenizer([
59
  "鈴木は4月の陽気の良い日に、鈴をつけて熊本県の阿蘇山に登った",
60
  "中国では、中国共産党による一党統治が続く",
61
- ], truncation=True, max_length=512, return_tensors="pt")
 
62
 
63
  sample_encoding = {k: v.to(device) for k, v in sample_encoding.items()}
64
 
@@ -70,7 +66,7 @@ class JapaneseNER():
70
  print("Predicted labels:", predicted_label_id)
71
 
72
  def predict(self, text):
73
- encoding = self.tokenizer([text], truncation=True, max_length=512, return_tensors="pt")
74
  encoding = {k: v.to(device) for k, v in encoding.items()}
75
 
76
  # Perform prediction
 
 
 
 
1
 
 
 
2
  # -*- coding: utf-8 -*-
3
  """
4
  Created on Tue Sep 17 19:03:17 2024
 
53
  sample_encoding = self.tokenizer([
54
  "鈴木は4月の陽気の良い日に、鈴をつけて熊本県の阿蘇山に登った",
55
  "中国では、中国共産党による一党統治が続く",
56
+ ], truncation=True,padding=True, # Ensure all sequences are of the same length
57
+ max_length=512, return_tensors="pt")
58
 
59
  sample_encoding = {k: v.to(device) for k, v in sample_encoding.items()}
60
 
 
66
  print("Predicted labels:", predicted_label_id)
67
 
68
  def predict(self, text):
69
+ encoding = self.tokenizer([text], truncation=True,padding=True, max_length=512, return_tensors="pt")
70
  encoding = {k: v.to(device) for k, v in encoding.items()}
71
 
72
  # Perform prediction