Comments (7)
会有这个问题。
您可以在读取patch的地方,加上捕获openslide.lowlevel.OpenSlideError
异常的代码,以跳过部分无法读取的patch。
也就是这行代码附近,
img = self.wsi.read_region(coord, self.patch_level, (self.patch_size, self.patch_size)).convert('RGB')
。
from advmil.
经过查阅资料,有可能是分割参数有问题,CLAM文件有预设分割参数,再presets文件里面,您还记得你对Clamelyon还有NLST的分割参数吗?
from advmil.
我使用参数和CLAM一样。有时会遇到您提到的问题。据观察,少部分无法读取的patch一般都落在背景区域,所以在实验中,我们通过捕获异常的方式直接跳过了此类patch。
from advmil.
您还记得您的异常捕获代码吗?我这个代码会报错
def getitem(self, idx):
with h5py.File(self.file_path,'r') as hdf5_file:
coord = hdf5_file['coords'][idx]
try:
img = self.wsi.read_region(coord, self.patch_level, (self.patch_size, self.patch_size)).convert('RGB')
except openslide.lowlevel.OpenSlideError:
print(f"Failed to read region at coordinates: {coord}")
return None, None
if self.target_patch_size is not None:
img = img.resize(self.target_patch_size)
img = self.roi_transforms(img).unsqueeze(0)
return img, coord
from advmil.
您可以给下具体的错误信息
from advmil.
具体记不得了,通过查阅历史记录看到有此类报错。
File "/home/ubuntu/CLAM/utils/utils.py", line 41, in collate_features
img = torch.cat([item[0] for item in batch], dim = 0)
TypeError: expected Tensor as element 392 in argument 0, but got NoneType
您可以分享下您那段异常捕捉的代码吗
from advmil.
我用的代码跟你贴的类似。根据你提供的错误信息,貌似是错误是因为item中存在None,大概跟读取patch错误无关。
from advmil.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from advmil.