UPD: Processing state

This commit is contained in:
Евгений Гурьев | Eugene Gourieff | 古仁
2025-01-18 13:31:35 +07:00
parent c20f3a3aff
commit 260d8ebbba
2 changed files with 13 additions and 6 deletions
+4 -4
View File
@@ -7,7 +7,7 @@ SCORE = 0.85
logging.getLogger('transformers').setLevel(logging.ERROR)
def nsfw_image(img_path: str, model_path: str):
img = Image.open(img_path)
predict = pipeline("image-classification", model=model_path)
result = predict(img)
return True if result[0]["score"] > SCORE else False
with Image.open(img_path) as img:
predict = pipeline("image-classification", model=model_path)
result = predict(img)
return True if result[0]["score"] > SCORE else False