Array API

Abierto
#22 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
30/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
python
Área
data

Línea de trabajo

Comienza reproduciendo el ejemplo de procesamiento de imágenes proporcionado e inspecciona la implementación de _asarray alrededor de la línea 145 indicada, especialmente el acceso a Array._array. Confirma por qué la ruta ndarray genera AttributeError y define done como gestionar la entrada mostrada sin esa excepción; en el issue no se nombra ningún test del repositorio ni ningún archivo fuente.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

I believe there's an issue with passing in any value to _asarray. The function refuses to create this image's values despite tedious restructuring. I can provide more code and details if you like, but here is the general code implementation below.

filename = "godfather.jpg"
img = mpimg.imread(filename)
img = rgb2gray(img)
plt.imshow(img, cmap='gray')
def flatten_comprehension(matrix):
    return [item for row in matrix for item in row]
imgL = flatten_comprehension(img)
image = np.reshape(np.asarray(imgL, dtype=np.float32), (600, 900), copy=True)
gradient_magnitude, gradient_direction = sobel_filters(image)

img when implemented here is just an nparray from .imread, have to do a lot of weird tricks to get around the first error (worked w @syurkevi on this)
here's the error stack trace

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[42], line 11
      7 image = np.reshape(np.asarray(imgL, dtype=np.float32), (600, 900), copy=True)
      8 # print(image.shape)
      9 # print(type(image))
     10 # print(image)
---> 11 gradient_magnitude, gradient_direction = sobel_filters(image)
     13 # Display the gradient magnitude as an image
     14 plt.figure(figsize=(10, 5))

Cell In[40], line 19
     16 Ky = np.asarray([[1, 2, 1], [0, 0, 0], [-1, -2, -1]])
     18 # Convolve with Kx and Ky using custom convolve2d function
---> 19 Ix = convolve2d(img, Kx)
     20 Iy = convolve2d(img, Ky)
     22 # Compute gradient magnitude and direction

Cell In[40], line 5
      1 def convolve2d(image, kernel):
      2     """
      3     Apply a 2D convolution operation without padding.
      4     """
----> 5     newImg = np.asarray(image, dtype=np.float32)
      6     output = np.zeros_like(newImg)  # Prepare the output array
...
--> 145     afarray = Array._array if not copy else af.copy_array(Array._array)
    146 elif isinstance(obj, list | tuple):
    147     afarray = _process_nested_sequence(obj)

AttributeError: type object 'Array' has no attribute '_array'

Lenguaje dominante
Python
Estrellas
2
Forks
5
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de arrayfire/arrayfire-py

Todos los issues de arrayfire/arrayfire-py

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.