huolongguo10 commited on
Commit
460ac8e
1 Parent(s): 5fffa22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -19,22 +19,22 @@ def _check_each(text):
19
  with torch.no_grad():
20
  logits = _model(**inputs).logits
21
  predicted_class_id = logits.argmax().item()
22
- print(f'{logits.argmax().item()}:{text}')
23
  return 'secure' if predicted_class_id==0 else 'insecure'
24
  def _check(text):
25
  t=text
26
  while len(t)>512:
27
- t=t[0:511]
28
- if check_each(t)=='insecure':
29
  return 'insecure'
 
30
  return check_each(t)
31
  def _check_tiny(text):
32
  t=text
33
  while len(t)>512:
34
- t=t[0:511]
35
- if _check_each(t)=='insecure':
36
  return 'insecure'
37
- return _check_each(t)
 
38
  def check(text):
39
  return _check(text),_check_tiny(text)
40
  with gr.Blocks() as demo:
 
19
  with torch.no_grad():
20
  logits = _model(**inputs).logits
21
  predicted_class_id = logits.argmax().item()
22
+ print(f't-{logits.argmax().item()}:{text}')
23
  return 'secure' if predicted_class_id==0 else 'insecure'
24
  def _check(text):
25
  t=text
26
  while len(t)>512:
27
+ if check_each(t[0:511])=='insecure':
 
28
  return 'insecure'
29
+ t=t[512:]
30
  return check_each(t)
31
  def _check_tiny(text):
32
  t=text
33
  while len(t)>512:
34
+ if check_each(t[0:511])=='insecure':
 
35
  return 'insecure'
36
+ t=t[512:]
37
+ return check_each(t)
38
  def check(text):
39
  return _check(text),_check_tiny(text)
40
  with gr.Blocks() as demo: