-
Notifications
You must be signed in to change notification settings - Fork 51
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
About Saving Unet The Results in .h5 format #115
Comments
Hi @fharman , I did not provide a script to perform the inference using the functional models (the old ones). Can you show me the code you used so that I can help you debug it? I just tested to see whether the sequences in from fastmri_recon.data.sequences.fastmri_sequences import ZeroFilled2DSequence
test_path = ... # your test path here
seq_4 = ZeroFilled2DSequence(
test_path,
mode='testing',
af=4,
contrast=None,
norm=True,
)
seq_8 = ZeroFilled2DSequence(
test_path,
mode='testing',
af=8,
contrast=None,
norm=True,
)
print(len(seq_4.filenames), len(seq_8.filenames)) Which returns |
Ok I see now, let me see. |
So your function def save_figure(im_recos, name):
global img_index
with h5py.File(test_gen_scaled.filenames[img_index],'r') as f:
for slice_index in range(f.get('kspace').shape[0]):
im_reco = im_recos[ slice_index ]
image_name=test_gen_scaled.filenames[img_index][78:len(test_gen_scaled.filenames[img_index])-6]
# im_gt = img_batch[slice_index]
# im_res = np.abs(im_gt - im_reco)
fig, ax = plt.subplots ( 1, frameon=False )
ax.imshow ( np.abs ( np.squeeze ( im_reco ) ), aspect='auto' )
ax.axis ( 'off' )
fig.savefig (f'/content/drive/My Drive/fastmri-reproducible-benchmark-bcd3fddb48ad324566a44b23c4439ff7a50a316e/TestFigures2/AF8/{image_name}_{slice_index}_{name}_recon_af{AF}.png' )
# fig, ax = plt.subplots(1, frameon=False)
# ax.imshow(np.abs(np.squeeze(im_res)), aspect='auto')
# ax.axis('off')
# fig.savefig(f'/content/drive/My Drive/UNET_Colab/fastmri_reproducible_benchmark_master/TestFigures/trivial_{name}_residu_af{AF}.png')
img_index += 1 However, you didn't open the correct file, you opened the original test file rather than a newly created output file with the correct naming (see the guidelines here). Also, I think in Python it's recommended to not use global variables in the general case, you should try rewriting this function also without a global variable. |
Hi,
I did not understand your correction. But i gave a link about a
reconstructed folder for an old unet commit bcd3fdd.(with AF4 and AF8)
https://drive.google.com/drive/folders/1J3_3t-VmosMR0-vQhVZN7WdZX8QHLpQg?usp=sharing
With the latest version, the reconstructed folder is like this.
https://drive.google.com/drive/folders/1StJVuOLI-FT0qRGhgwjhqRkaWo0GCSpx?usp=sharing
Thank you
Zaccharie Ramzi <notifications@github.com>, 26 Kas 2020 Per, 20:57
tarihinde şunu yazdı:
… In the colab you linked
<https://colab.research.google.com/drive/1S3Xzn9UXG6Zrz1Q0jlTMqsHluTmCjvt5>,
I didn't see where you performed the inference to predict the test images.
Also please note that since #113
<#113>
you no longer need to switch to an older commit for correct results using
the U-net, I corrected the error.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#115 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AO4IQ2UJFTWIUQ25EFBPXYLSR2JIHANCNFSM4UDU2VIA>
.
|
@fharman I did not do any correction in the function, I just rewrote it in the issue for logging's sake. The folders you are showing me are full of png images. For this challenge you need to submit h5 files: please read the guidelines on how to submit. Alternatively, you can also take inspiration from this function or the one of the official repo. |
Thank you for your recommendation.
But i still don't understand what you mean just saying
However, you didn't open the correct file, you opened the original test
file rather than a newly created output file with the correct naming (see
the guidelines here <https://fastmri.org/submission_guidelines/#leaderboard>
).
Also, in this function, you never write to that file but instead save a
matplotlib figure, you should save to the newly created h5 file instead.
Please let me know the information about details and my faults in
reconstruction.
Thank you again,
Zaccharie Ramzi <notifications@github.com>, 26 Kas 2020 Per, 21:05
tarihinde şunu yazdı:
… So your function save_figure (consider changing the name for greater
readability) is the one that I guess you wanted to use to save your results
(I am rewriting it here for clarity).
def save_figure(im_recos, name):
global img_index
with h5py.File(test_gen_scaled.filenames[img_index],'r') as f:
for slice_index in range(f.get('kspace').shape[0]):
im_reco = im_recos[ slice_index ]
image_name=test_gen_scaled.filenames[img_index][78:len(test_gen_scaled.filenames[img_index])-6]
# im_gt = img_batch[slice_index]
# im_res = np.abs(im_gt - im_reco)
fig, ax = plt.subplots ( 1, frameon=False )
ax.imshow ( np.abs ( np.squeeze ( im_reco ) ), aspect='auto' )
ax.axis ( 'off' )
fig.savefig (f'/content/drive/My Drive/fastmri-reproducible-benchmark-bcd3fddb48ad324566a44b23c4439ff7a50a316e/TestFigures2/AF8/{image_name}_{slice_index}_{name}_recon_af{AF}.png' )
# fig, ax = plt.subplots(1, frameon=False)
# ax.imshow(np.abs(np.squeeze(im_res)), aspect='auto')
# ax.axis('off')
# fig.savefig(f'/content/drive/My Drive/UNET_Colab/fastmri_reproducible_benchmark_master/TestFigures/trivial_{name}_residu_af{AF}.png')
img_index += 1
However, you didn't open the correct file, you opened the original test
file rather than a newly created output file with the correct naming (see
the guidelines here
<https://fastmri.org/submission_guidelines/#leaderboard>).
Also, in this function, you never write to that file but instead save a
matplotlib figure, you should save to the newly created h5 file instead.
Also, I think in Python it's recommended to not use global variables in
the general case, you should try rewriting this function also without a
global variable.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#115 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AO4IQ2UQYMNL7RPYUF5BMM3SR2KF7ANCNFSM4UDU2VIA>
.
|
Thank you for the clarification.
26 Kas 2020 Per 21:16 tarihinde Zaccharie Ramzi <notifications@github.com>
şunu yazdı:
… @fharman <https://github.com/fharman> I did not do any correction in the
function, I just rewrote it in the issue for logging's sake.
The folders you are showing me are full of png images. For this challenge
you need to submit h5 files: please read the guidelines
<https://fastmri.org/submission_guidelines/#leaderboard> on how to submit.
Alternatively, you can also take inspiration from this function
<https://github.com/zaccharieramzi/fastmri-reproducible-benchmark/blob/master/fastmri_recon/evaluate/utils/write_results.py>
or the one of the official repo
<https://github.com/facebookresearch/fastMRI/blob/master/fastmri/utils.py>
.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#115 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AO4IQ2VVXDPY5GUHIAXLXG3SR2LO7ANCNFSM4UDU2VIA>
.
|
Hi, Sorry for my faults and misunderstanding. But I try to learn and revise myself according to your reply. I want to ask you about fastmri-reproducible-benchmark/fastmri_recon/evaluate/utils/write_results.py / write_result(exp_id, result, filename, coiltype='multicoil', scale_factor=1e6, brain=False, challenge=False) in this line, what is exp_id? Thank you for your patience and reply, Best, |
I added a Pull Request (PR) where I specify the docs of this function. Please take a look. |
Thanks, I'll check it out.
Zaccharie Ramzi <notifications@github.com>, 27 Kas 2020 Cum, 16:20
tarihinde şunu yazdı:
… I added a Pull Request (PR) where I specify the docs of this function.
Please take a look
<https://github.com/zaccharieramzi/fastmri-reproducible-benchmark/pull/118/files#diff-f117a68dfd3fedc5e30ed3f1d2ce827f82e0e2973d06bb44812712f59a618525R22>
.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#115 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AO4IQ2TQ35AMQ3JMRA2RPZDSR6RRZANCNFSM4UDU2VIA>
.
|
@fharman it's because the |
Hi @fharman , Can we close this? |
Hi,
Thank you for your help. I sent it and finally reached a result for
improvement.
Thanks,
19 Ara 2020 Cmt 21:35 tarihinde Zaccharie Ramzi <notifications@github.com>
şunu yazdı:
… Hi @fharman <https://github.com/fharman> ,
Can we close this?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#115 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AO4IQ2XVFAJWQX6LDDWXL6DSVTW5NANCNFSM4UDU2VIA>
.
|
Hi,
I saved the model for Fastmri Public Leaderboard but always encountered an error as EvalException: file1001066_v2.h5 does not exist in your submission. It is available in that folder. How did you save and upload your model results that i really want to know?
Thank you for all your support,
Best Regards,
The text was updated successfully, but these errors were encountered: