From 2cd3f6d1b3750a6525a54d00749d672f5df38a0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksandar=20Toma=C5=A1evi=C4=87?= Date: Thu, 7 Dec 2023 10:05:22 -0500 Subject: [PATCH] Fix conda environment setup and update function name --- R/image_scores.R | 8 ++++---- inst/python/video.py | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/R/image_scores.R b/R/image_scores.R index c94a259..5cc9507 100644 --- a/R/image_scores.R +++ b/R/image_scores.R @@ -20,14 +20,14 @@ image_scores <- function(image_file, classes, face_selection = "largest"){ - # - # check if active condaenv is transforEmotion - if(grepl("transforEmotion", reticulate::py_config()$python) == FALSE){ + if (!(reticulate::condaenv_exists("transforEmotion"))){ print("Creating and switching to transforEmotion virtual Python environment...") Sys.sleep(1) setup_miniconda() + } else + { + reticulate::use_condaenv("transforEmotion", required = FALSE) } - # check if transformer library can be loadedd into conda env if (!reticulate::py_module_available("transformers") &!reticulate::py_module_available("face_recognition")){ print("Some Python libraries are not available in the transforEmotion conda environment. We are going to set them up. We need them for facial recognition and emotion detection in text, images and video. This may take a while, please be patient.") Sys.sleep(1) diff --git a/inst/python/video.py b/inst/python/video.py index 630472a..3801a64 100644 --- a/inst/python/video.py +++ b/inst/python/video.py @@ -18,8 +18,9 @@ import time import shutil + def yt_analyze(url, nframes, labels, probability=True, side='largest', cut = 'no', start = 0, end=60, uniform = False, ff = 10, save_video = False, save_frames = False, frame_dir = 'temp/', video_name = 'temp'): - text_embeds_openai = get_text_embeds_openai(labels) + text_embeds_openai = get_text_embeds(labels) start_time = time.time() temp_dir = frame_dir if not os.path.exists(temp_dir):