Switched detach for no_grad():
Browse files
app.py
CHANGED
|
@@ -31,9 +31,11 @@ def moderate_image(img):
|
|
| 31 |
|
| 32 |
|
| 33 |
def classify_toxic(text):
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
return output
|
| 38 |
|
| 39 |
|
|
|
|
| 31 |
|
| 32 |
|
| 33 |
def classify_toxic(text):
|
| 34 |
+
with torch.no_grad():
|
| 35 |
+
batch = tokenizer.encode(text, return_tensors="pt")
|
| 36 |
+
output = model(batch).logits
|
| 37 |
+
probabilities = torch.nn.functional.softmax(output, dim=-1)
|
| 38 |
+
print(f"Output: {probabilities}")
|
| 39 |
return output
|
| 40 |
|
| 41 |
|