Skip to content

Auto Visualization - #26

Open
wanze-zhang wants to merge 3 commits into
mainfrom
Wanze/auto-run
Open

Auto Visualization#26
wanze-zhang wants to merge 3 commits into
mainfrom
Wanze/auto-run

Conversation

@wanze-zhang

Copy link
Copy Markdown
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
Comment thread 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
Copy Markdown
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
Copy Markdown
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 :)

@nicolepeverley nicolepeverley left a comment

Copy link
Copy Markdown
Collaborator

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?

Comment thread auto_run.py

# 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread auto_run.py
output_dim=OUTPUT_DIM,
num_hg_blocks=eval.num_hg_blocks,
shuffle=False,
batch_size=len(test_df),

Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread auto_run.py
x.append(keypoints[i,0])
y.append(keypoints[i,1])
plt.scatter(x,y)
plt.imshow(img)

Copy link
Copy Markdown
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]

Comment thread auto_run.py
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:

@julianrocha julianrocha Mar 31, 2021

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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 :)

@Ckoelewyn Ckoelewyn left a comment

Copy link
Copy Markdown
Collaborator

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