-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
predict.py报错 #4
Comments
出错
出错地方是将源数据格式uint16转成uint8,这段代码: def uint16to8(bands, lower_percent=0.001, higher_percent=99.999):
out = np.zeros_like(bands,dtype = np.uint8)
n = bands.shape[0]
for i in range(n):
a = 0 # np.min(band)
b = 255 # np.max(band)
c = np.percentile(bands[i, :, :], lower_percent)
d = np.percentile(bands[i, :, :], higher_percent)
t = a + (bands[i, :, :] - c) * (b - a) / (d - c)
t[t<a] = a
t[t>b] = b
out[i, :, :] = t
return out 实在不好意思,由于我不做这个项目了,手边也没有数据集,无法运行
t = a + (bands[i, :, :] - c) * (b - a) / (d - c) 改成 t = a + (bands[i, :, :] - c) * (b - a) / (d - c + 1e-9) 直接增加一个很小的数来避免除以0,但是不知道会不会造成不可预料的后果,你可以先试试,这个方法不行的话,再去问问GPT。
|
好的谢谢您~我去试一试!:D
从 Windows 版邮件发送
发件人: Ikun
发送时间: 2023年8月22日 17:12
收件人: Phoenix-Shen/DSEN2_CR_PYTORCH
抄送: m47777; Author
主题: Re: [Phoenix-Shen/DSEN2_CR_PYTORCH] predict.py报错 (Issue #4)
出错
作者您好,我在跑predict.py的时候时间过长,在加载完数据集后报了一个warning:RuntimeWarning: invalid value encountered in true_divide,查看报错位置是t = a + (bands[i, :, :] - c) * (b - a) / (d - c),目前加了代码np.seterr(divide='ignore',invalid='ignore')忽略这个报错,但是还是时间过长,没有结果。请问您有遇到过这个问题以及解决办法吗T-T
出错地方是将源数据格式uint16转成uint8,这段代码:
def uint16to8(bands, lower_percent=0.001, higher_percent=99.999):
out = np.zeros_like(bands,dtype = np.uint8)
n = bands.shape[0]
for i in range(n):
a = 0 # np.min(band)
b = 255 # np.max(band)
c = np.percentile(bands[i, :, :], lower_percent)
d = np.percentile(bands[i, :, :], higher_percent)
t = a + (bands[i, :, :] - c) * (b - a) / (d - c)
t[t<a] = a
t[t>b] = b
out[i, :, :] = t
return out
实在不好意思,由于我不做这个项目了,手边也没有数据集,无法运行predict.py,但是我还是可以提供一些解决方法:
1. 应该是(d - c) 这个项中出现了0值,所以进行除法的时候就会寄掉,可以尝试问问GPT或者NEW BING来看看相关解决方法,这里我个人觉得一个最直接的办法就是将
t = a + (bands[i, :, :] - c) * (b - a) / (d - c)
改成
t = a + (bands[i, :, :] - c) * (b - a) / (d - c + 1e-9)
直接增加一个很小的数来避免除以0,但是不知道会不会造成不可预料的后果,你可以先试试,这个方法不行的话,再去问问GPT。
3. 可以尝试降低numpy版本来进行,我当时进行试验的时候用的是python3.7,conda创建个新环境使用低版本numpy跑一下或许不会报错。
4. 检查一下数据集是否出错。
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
作者您好,我在跑predict.py的时候时间过长,在加载完数据集后报了一个warning:RuntimeWarning: invalid value encountered in true_divide,查看报错位置是
t = a + (bands[i, :, :] - c) * (b - a) / (d - c)
,目前加了代码np.seterr(divide='ignore',invalid='ignore')
忽略这个报错,但是还是时间过长,没有结果。请问您有遇到过这个问题以及解决办法吗T-TThe text was updated successfully, but these errors were encountered: