benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 6544939c-658b-5d5f-a0d5-248d9f592b08

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import cv2
import numpy as np
import os

def task_func(img_path):
    """
    Open an RGB image, convert it to grayscale, find contours using the cv2 library, and return the original image and contours.

    Parameters:
    - img_path (str): The path of the image file.

    Returns:
    - tuple: A tuple containing the original image as a numpy array and a list of contours.

    Raises:
    - FileNotFoundError: If the image file does not exist at the specified path.

    Requirements:
    - opencv-python
    - numpy
    - os

    Example:
    >>> img_path = 'sample.png'
    >>> create_dummy_image(image_path=img_path)
    >>> img, contours = task_func(img_path)
    >>> os.remove(img_path)
    """

instruct prompt

Open an RGB image, convert it to grayscale, find contours using the cv2 library, and return the original image and contours.
The function should raise the exception for: FileNotFoundError: If the image file does not exist at the specified path.
The function should output with:
    tuple: A tuple containing the original image as a numpy array and a list of contours.
You should write self-contained code starting with:

Code

import cv2
import numpy as np
import os
def task_func(img_path):

code prompt

Code

import cv2
import numpy as np
import os
def task_func(img_path):

entry point

task_func

libs

  • numpy
  • cv2
  • os

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import