Merge branch 'next' into issue_511_opencv_unicode_paths

This commit is contained in:
Pozitronik 2023-06-18 22:51:53 +04:00
commit 44c3c790c6
2 changed files with 3 additions and 4 deletions

View File

@ -1,7 +1,6 @@
import numpy
import opennsfw2
from PIL import Image
from opennsfw2 import predict_video_frames
MAX_PROBABILITY = 0.85
@ -16,9 +15,9 @@ def predict_frame(target_frame: Image) -> bool:
def predict_image(target_path: str) -> bool:
return predict_image(target_path) > MAX_PROBABILITY
return opennsfw2.predict_image(target_path) > MAX_PROBABILITY
def predict_video(target_path: str) -> bool:
_, probabilities = predict_video_frames(video_path=target_path, frame_interval=100)
_, probabilities = opennsfw2.predict_video_frames(video_path=target_path, frame_interval=100)
return any(probability > MAX_PROBABILITY for probability in probabilities)

View File

@ -65,7 +65,7 @@ def restore_audio(target_path: str, output_path: str) -> None:
def get_temp_frame_paths(target_path: str) -> List[str]:
temp_directory_path = get_temp_directory_path(target_path)
return glob.glob(os.path.join(temp_directory_path, '*.png'))
return glob.glob((os.path.join(glob.escape(temp_directory_path), '*.png')))
def get_temp_directory_path(target_path: str) -> str: