arrayfire / arrayfire/arrayfire-py

Array API

未關閉
#22 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
2
分支
5
PR 合併指標
30 天內沒有已合併 PR

描述

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'

```

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

先重現提供的影像處理範例,並檢查回報行 145 附近的 _asarray 實作,尤其是對 Array._array 的存取。確認為什麼 ndarray 路徑會引發 AttributeError,並將 done 定義為能夠處理所示輸入而不發生該例外;issue 中沒有指定 repository 測試或原始檔案。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
data
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
30/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。