Spaces:
Running
Running
Update app.py
Browse files
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])
|
|
|
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]
|
|
|
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")
|