Problem running simple example with Reticulate in RStudio Cloud

Previously, I installed all the necessary libraries.

The python code I'd like to reproduce with reticulate:

import cvlib as cv
import cv2

img = cv2.imread(sys.argv[1])
bbox, label, conf = cv.detect_common_objects(img)

What I had tried:

library(reticulate)
cv <- import("cvlib")
cv2 <- import("cv2")

temp = list.files(pattern = "*.jpg")
img <- cv2$imread(temp)

cv$detect_common_objects(img)

The erro message:

 Error in py_call_impl(callable, dots$args, dots$keywords) : 
  error: OpenCV(4.0.0) /io/opencv/modules/imgproc/src/resize.cpp:3662: error: (-215:Assertion failed) func != 0 in function 'resize' 

Here follows the project with the environment configuration and image:
Project Link

Any help is appreciated.
Thanks in advance!

For what it is worth, when I used the Terminal to run your Python directly, the process was killed due to exceeding the memory limit of 1 GB. It is quite likely that the error you are seeing when calling via reticulate is masking the same issue.

2 Likes

Thank you @josh, but I couldn't reproduce it on terminal.
For debugging purposes, how could I also see it?

When I tried to run it on the terminal I saw:

Error in py_call_impl(callable, dots$args, dots$keywords) :
  error: OpenCV(4.0.0) /io/opencv/modules/imgproc/src/resize.cpp:3662: error: (-215:Assertion failed) func != 0 in function 'resize'


Detailed traceback:
  File "/cloud/project/r-reticulate/lib/python2.7/site-packages/cvlib/object_detection.py", line 79, indetect_common_objects
    blob = cv2.dnn.blobFromImage(image, scale, (416,416), (0,0,0), True, crop=False)

You are trying to run R in the terminal, I was speaking of running the straight Python:

1 Like

@josh I see it now! Thank you!
Do you have any information when It will be possible expand the memory limit in RStudio Cloud?

I don't have a timeframe to share at this time, sorry!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.