Open Leprechault opened 4 months ago
Hi @Leprechault, does this part of your code work on its own without Shiny?
library(reticulate)
# Create a py_env environment and install: pip install ultralytics
setwd('C:/Users/IFMT/anaconda3/envs/py_env')
renv::init()
Sys.setenv(RENV_PATHS_CACHE = 'C:/Users/IFMT/anaconda3/envs/py_env')
renv::use_python(type = 'conda', name = 'py_env')
#
#Create a new Python file, e.g., yolov8_loader.py, with the following content inside the py_env environment:
# import ultralytics as yolo
#
# def load_model():
# model = yolo.YOLO("https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.pt")
# return model
# Load the Python module
yolov8_loader <- source_python("yolov8_loader.py")
# Import the load_model function
load_model <- yolov8_loader$load_model
# Load the model
load_model()
I suspect that the errors you're seeing are related to reticulate and the yolo model. If that part of the code works, but starts to fail when you involve Shiny, then we can help. Otherwise, I'd recommend you ask for help on https://forum.posit.co where others who have more experience with reticulate might be able to help you.
Another small note that Shiny for Python might be a great fit for this app, especially if you're using a Python-specific model. As a long-time Shiny for R users, I found it surprisingly easy to start using Shiny for Python and you might have a similar experience.
I want to create a Shiny app using R and Python cause the Yolov8 model was developed in Python. But, I try to use my app calling a *py code (
yolov8_loader.py
) in my app directory and it doesn't work, without any error.In my example:
But the
yolov8_loader
object is always:Please, any help with this bug?
Alexandre