carpedm20 / carpedm20/DCGAN-tensorflow
ValueError: could not broadcast input array from shape (1,2048) into shape (98,1024)
- Dominant language
- JavaScript
- Stars
- 7.2k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to build a Attention mechanism for Medical report Generation using Chest X-rays.
train, test = train_test_split(data, test_size = 0.2, random_state = 1, shuffle = True)
print(train.shape) - (3056, 4)
print(test.shape) - (764, 4)
**Function for Extracting the Images:**
def image_feature_extraction(image1,image2):
image_1 = Image.open(image1).convert('RGB')
image_1 = np.asarray(image_1)
image_2 = Image.open(image2).convert('RGB')
image_2 = np.asarray(image_2)
#normalize the values of the image
image_1 = image_1/255
image_2 = image_2/255
#resize all image into (224,224)
image_1 = cv2.resize(image_1,(224,224))
image_2 = cv2.resize(image_2,(224,224))
image_1 = np.expand_dims(image_1, axis=0)
image_2 = np.expand_dims(image_2, axis=0)
#now we have read two image per patient. this is goven to the chexnet model for feature extraction
image_1_out = final_chexnet_model(image_1)
image_2_out = final_chexnet_model(image_2)
#conactenate along the width
conc = np.concatenate((image_1_out,image_2_out),axis = -1)
#reshape into(no.of images passed, length*breadth, depth)
image_feature=tf.reshape(conc,(conc.shape[0], -1, conc.shape[-1]))
#image_feature = feature_extraction_model([image_1,image_2])
return image_feature
print(image_2_out)
KerasTensor(type_spec=TensorSpec(shape=(None, 1024), dtype=tf.float32, name=None), name='Chexnet_model/avg_pool/Mean:0', description="created by layer 'Chexnet_model'")
train_features = np.zeros((3056,98,1024))
for row in tqdm(range(train.shape[0])):
image_1=train.iloc[row]["image1"]
image_2=train.iloc[row]["image2"]
train_features[row] = (image_feature_extraction(image_1,image_2))
0%| | 0/3056 [00:00 in
2 image_1=train.iloc[row]["image1"]
3 image_2=train.iloc[row]["image2"]
----> 4 train_features[row] = (image_feature_extraction(image_1,image_2))
**ValueError: could not broadcast input array from shape (1,2048) into shape (98,1024)**
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue names no repository file, test, or entry point; start by checking whether the reported TensorFlow/Keras code belongs to this repository and reproduce the traceback in the shown notebook context. Done is not defined because the report does not request a project change or identify an expected result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- keras, numpy, opencv, python, tensorflow
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 12/100