spuun commited on
Commit
60a0e47
1 Parent(s): 38696b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -48,7 +48,8 @@ def launch(img):
48
  tm_image = load_image(img, mode='RGB')
49
  tm_input_ = _img_encode(tm_image, size=(256, 256))[None, ...]
50
  tm_items, = nsfw_tm.run(['output'], {'input': tm_input_})
51
- tm_output = sorted(list(zip(tm_cfg["labels"], map(lambda x: x.item(), tm_items[0]))), key=lambda x: x[1])[0][0]
 
52
 
53
  match tm_output:
54
  case "safe":
@@ -68,7 +69,8 @@ def launch(img):
68
  case "r18":
69
  weight += 2
70
 
71
- print(sorted(list(zip(tm_cfg["labels"], map(lambda x: x.item(), tm_items[0]))), key=lambda x: x[1]), tf_output)
 
72
  return weight > 0
73
 
74
  app = gr.Interface(fn=launch, inputs="pil", outputs="text")
 
48
  tm_image = load_image(img, mode='RGB')
49
  tm_input_ = _img_encode(tm_image, size=(256, 256))[None, ...]
50
  tm_items, = nsfw_tm.run(['output'], {'input': tm_input_})
51
+ tm_output = sorted(list(zip(tm_cfg["labels"], map(lambda x: x.item(), tm_items[0]))), key=lambda x: x[1], reverse=True)
52
+ )[0][0]
53
 
54
  match tm_output:
55
  case "safe":
 
69
  case "r18":
70
  weight += 2
71
 
72
+ print(sorted(list(zip(tm_cfg["labels"], map(lambda x: x.item(), tm_items[0]))), key=lambda x: x[1], reverse=True)
73
+ ), tf_output)
74
  return weight > 0
75
 
76
  app = gr.Interface(fn=launch, inputs="pil", outputs="text")