Comments (2)
Hello, I try the code and face the same problem
I use command:
python tools/splicing_augmentation_Cityscapes.py --input_root "CityScape" --out_root "Augmentation" --thread_num 7
In the File "/workspace/my_code/DatasetDM/model/unet.py", line 153, in forward
reshape_h=h.reshape(int(h.size()[0]/2),int(h.size()[1]*2),h.size()[2],h.size()[3])
IndexError:tuple index out of range
I debuged the code and found that
the upsample code is
sample, res_samples= upsample_block(
hidden_states=sample,
temb=emb,
res_hidden_states_tuple=res_samples,
encoder_hidden_states=encoder_hidden_states,
)
However in the diffusers the diffusers/src/diffusers/models/unet_2D_blocks.py class CrossAttnUpBlock2D and class UpBlock2D the 'def forward' only have one return variable called hidden_states in type of 'tensors' [2,1280,8,8]. the function above uses two variable samples and res_samples, it is separated to [1280,8,8] and [1280,8,8]. However, in the previous downsample part the class return a tensor(hidden states) and tuple(output_samples). In the for loop the [1280,8,8] was separated to [8,8], so the tuple index out of range.
I recommend to use another code:
in the unet.py
in the upsample part new code:
for upsample_block in self.up_blocks:
res_samples = down_block_res_samples[-len(upsample_block.resnets) :]
down_block_res_samples = down_block_res_samples[: -len(upsample_block.resnets)]
if hasattr(upsample_block, "attentions") and upsample_block.attentions is not None:
sample= upsample_block(
hidden_states=sample,
temb=emb,
res_hidden_states_tuple=res_samples,
encoder_hidden_states=encoder_hidden_states,
)
else:
sample = upsample_block(hidden_states=sample, temb=emb, res_hidden_states_tuple=res_samples)
if flag_time:
# reshape_h=sample.reshape(int(h.size()[0]/2),int(h.size()[1]*2),h.size()[2],h.size()[3])
print(sample.shape)
reshape_h=sample.reshape(int(sample.size()[0]/2),int(sample.size()[1]*2),sample.size()[2],sample.size()[3])
reshape_h=sample.reshape(int(sample.size()[0]/2),int(sample.size()[1]*2),sample.size()[2],sample.size()[3])
if reshape_h.size()[2]==8:
all_feature_dic["low"].append(reshape_h)
elif reshape_h.size()[2]==16:
all_feature_dic["mid"].append(reshape_h)
elif reshape_h.size()[2]==32:
all_feature_dic["high"].append(reshape_h)
elif reshape_h.size()[2]==64:
all_feature_dic["highest"].append(reshape_h)
from datasetdm.
for upsample_block in self.up_blocks:
res_samples = down_block_res_samples[-len(upsample_block.resnets) :]
down_block_res_samples = down_block_res_samples[: -len(upsample_block.resnets)]
if hasattr(upsample_block, "attentions") and upsample_block.attentions is not None:
sample= upsample_block(
hidden_states=sample,
temb=emb,
res_hidden_states_tuple=res_samples,
encoder_hidden_states=encoder_hidden_states,
)
else:
sample = upsample_block(hidden_states=sample, temb=emb, res_hidden_states_tuple=res_samples)
if flag_time:
# reshape_h=sample.reshape(int(h.size()[0]/2),int(h.size()[1]*2),h.size()[2],h.size()[3])
print(sample.shape)
reshape_h=sample.reshape(int(sample.size()[0]/2),int(sample.size()[1]*2),sample.size()[2],sample.size()[3])
if reshape_h.size()[2]==8:
all_feature_dic["low"].append(reshape_h)
elif reshape_h.size()[2]==16:
all_feature_dic["mid"].append(reshape_h)
elif reshape_h.size()[2]==32:
all_feature_dic["high"].append(reshape_h)
elif reshape_h.size()[2]==64:
all_feature_dic["highest"].append(reshape_h)
from datasetdm.
Related Issues (20)
- question about coco dataset code HOT 2
- Training not working. HOT 4
- gt_classes in VOC2012.py HOT 4
- ./DataDiffusion/COCO_Train_5_images_t1_10layers_NoClass/Image/ HOT 1
- prompt txt files HOT 1
- About prompt in NYU dataset
- No module named 'torch.distributed.algorithms.join
- Accelerate training via training on multiple gpus HOT 1
- Weights about Depth Estimation
- CUDA out of memory - on 12 GB GPU
- Can't reproduce the results in other COCO-format instance segmentation dataset HOT 3
- exception when trying to generate data HOT 5
- generate_instance_coco HOT 2
- doing data augmentation with coco2017 dataset but no image or mask generate
- prepare NYU dataset
- adapt the synthetic data to Mask2Fomer model HOT 5
- dataset mode not defined while training HOT 1
- Error in init_latent in ptp_utils.py during training
- 在VOC2012.py中gt_classes为什么是1而不是select_class?
- Why is mapper_classes = [1] in VOC2012.py?
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 datasetdm.