Skip to content
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

Auto Visualization #26

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Auto Visualization #26

wants to merge 3 commits into from

Conversation

wanze-zhang
Copy link
Collaborator

auto_run.py is an extension of Julian's run_evaluation.py. It automatically runs the representative set for all models that are contained in a path and subdirectories within the path.

Small changes in constants.py to work with os.path.join().

@wanze-zhang wanze-zhang self-assigned this Mar 31, 2021
@wanze-zhang wanze-zhang changed the title Wanze/auto run Auto Visualization Mar 31, 2021
auto_run.py Outdated
Comment on lines 38 to 43
directory = os.listdir(os.path.join(base_dir, sub_dir))
weight_file = [f for f in directory if (f.endswith(".hdf5"))]
for name in weight_file:
match = re.search('hpe_epoch(\d+)', name)
if match:
epoch.append((match.group(1), sub_dir))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend dictionary here

Suggested change
directory = os.listdir(os.path.join(base_dir, sub_dir))
weight_file = [f for f in directory if (f.endswith(".hdf5"))]
for name in weight_file:
match = re.search('hpe_epoch(\d+)', name)
if match:
epoch.append((match.group(1), sub_dir))
epochs = {}
directory = os.listdir(os.path.join(base_dir, sub_dir))
weight_file = [f for f in directory if (f.endswith(".hdf5"))]
for name in weight_file:
match = re.search('^hpe_epoch(\d+)', name)
if match:
epochs[match.group] = sub_dir

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah good suggestion :)

Copy link
Collaborator

@nicolepeverley nicolepeverley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we planning on using auto_run.py as a callback function for after each epoch or run only at the end for all epochs?


# Get predicted keypoints from last hourglass (eval.num_hg_blocks-1)
keypoints = eval.heatmaps_to_keypoints(predict_heatmaps[eval.num_hg_blocks-1, 0, :, :, :])
print(keypoints)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to print the keypoints here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Emmm, not necessary when we are running multiple models but it's very useful when we want to dig into one image. The key point np.array tells us which joint the model is seeing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a callback function. We are running this at the very end. Enabling a callback function would significantly increase our running time.

output_dim=OUTPUT_DIM,
num_hg_blocks=eval.num_hg_blocks,
shuffle=False,
batch_size=len(test_df),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we only ever plan on passing the representative set, then this fine, but if we pass a test_df of the scale similar to our test set then it won't fit in memory. Will have to visualize in batches.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just past in the representative set for quick comparisons. It takes about 40 mins to run 10 epochs on the representative set for each model.

x.append(keypoints[i,0])
y.append(keypoints[i,1])
plt.scatter(x,y)
plt.imshow(img)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are running this on all our models, then we may want to save these images to disk, we also may want to visualize the representative set rather than just generator[168]

if '_hg_' in sub_dir and sub_dir not in models and sub_dir not in output_models:
models.append(sub_dir)
epoch = find_epochs(DEFAULT_MODEL_BASE_DIR, sub_dir, epoch, models)
for (n_epoch, model_file) in epoch:
Copy link
Collaborator

@julianrocha julianrocha Mar 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the models make large progress at the beginning and less so near the end, and because loading/visualizing takes some time, we may want to limit the epochs we visualize. So for example, only visualize epochs: [1,2,3,4,5,10,20,30,40] or something along those lines

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a very good point! I'll look into it :)

Copy link
Collaborator

@Ckoelewyn Ckoelewyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants