Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2e8f326

Browse files
committed
Getting the main in there as well
1 parent70da266 commit2e8f326

File tree

2 files changed

+124
-2
lines changed

2 files changed

+124
-2
lines changed

‎dense_correspondence/training/training.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ def run(self, loss_current_iteration=0, use_pretrained=False):
365365
im2=np.ascontiguousarray(im2)
366366

367367
# First show the matches:
368-
match_pixels_a=np.stack([matches_a%640,matches_a//640],axis=1)
369-
match_pixels_b=np.stack([matches_b%640,matches_b//640],axis=1)
368+
match_pixels_a=np.stack([blind_non_matches_a%640,blind_non_matches_a//640],axis=1)
369+
match_pixels_b=np.stack([blind_non_matches_b%640,blind_non_matches_b//640],axis=1)
370370

371371
iter=0
372372
form_a,m_binzip(match_pixels_a,match_pixels_b):

‎main.py‎

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
### Need some extra paths
2+
importsys,os
3+
sys.path.append('modules')
4+
sys.path.append('dense_correspondence/dataset')
5+
6+
### Set a few environment variables that would've been normally set in Docker
7+
os.environ["DC_SOURCE_DIR"]=os.getcwd()
8+
os.environ["DC_DATA_DIR"]="/home/michelism/Data/pdc"
9+
10+
importdense_correspondence_manipulation.utils.utilsasutils
11+
utils.add_dense_correspondence_to_python_path()
12+
fromdense_correspondence.training.trainingimport*
13+
importlogging
14+
15+
#utils.set_default_cuda_visible_devices()
16+
#utils.set_cuda_visible_devices([0]) # use this to manually set CUDA_VISIBLE_DEVICES
17+
18+
fromdense_correspondence.training.trainingimportDenseCorrespondenceTraining
19+
fromdense_correspondence.dataset.spartan_dataset_maskedimportSpartanDataset
20+
logging.basicConfig(level=logging.INFO)
21+
22+
fromdense_correspondence.evaluation.evaluationimportDenseCorrespondenceEvaluation
23+
24+
25+
importnumpyasnp
26+
np.random.seed(42)# Even this doesn't help... It's absolute chaos random.
27+
28+
29+
config_filename=os.path.join(utils.getDenseCorrespondenceSourceDir(),'config','dense_correspondence',
30+
'dataset','composite','caterpillar_upright.yaml')
31+
config=utils.getDictFromYamlFilename(config_filename)
32+
33+
train_config_file=os.path.join(utils.getDenseCorrespondenceSourceDir(),'config','dense_correspondence',
34+
'training','training.yaml')
35+
36+
train_config=utils.getDictFromYamlFilename(train_config_file)
37+
dataset=SpartanDataset(config=config)
38+
39+
logging_dir="trained_models/tutorials"
40+
num_iterations=3500
41+
d=3# the descriptor dimension
42+
name="caterpillar_%d"%(d)
43+
train_config["training"]["logging_dir_name"]=name
44+
train_config["training"]["logging_dir"]=logging_dir
45+
train_config["dense_correspondence_network"]["descriptor_dimension"]=d
46+
train_config["training"]["num_iterations"]=num_iterations
47+
48+
TRAIN=True
49+
EVALUATE=True
50+
51+
52+
53+
# All of the saved data for this network will be located in the
54+
# code/data/pdc/trained_models/tutorials/caterpillar_3 folder
55+
56+
ifTRAIN:
57+
#print "training descriptor of dimension %d" %(d)
58+
train=DenseCorrespondenceTraining(dataset=dataset,config=train_config)
59+
train.run()
60+
#print "finished training descriptor of dimension %d" %(d)
61+
62+
63+
model_folder=os.path.join(logging_dir,name)
64+
model_folder=utils.convert_data_relative_path_to_absolute_path(model_folder)
65+
66+
ifEVALUATE:
67+
DCE=DenseCorrespondenceEvaluation
68+
num_image_pairs=100
69+
DCE.run_evaluation_on_network(model_folder,num_image_pairs=num_image_pairs)
70+
71+
fromdense_correspondence.evaluation.evaluationimportDenseCorrespondenceEvaluationPlotterasDCEP
72+
73+
importmatplotlib.pyplotasplt
74+
75+
dc_data_dir=utils.get_data_dir()
76+
77+
folder_name="tutorials"
78+
net_to_plot=os.path.join(folder_name,"caterpillar_3")
79+
80+
network_name=net_to_plot
81+
path_to_csv=os.path.join(dc_data_dir,"trained_models",network_name,"analysis/train/data.csv")
82+
fig_axes=DCEP.run_on_single_dataframe(path_to_csv,label=network_name,save=False)
83+
84+
path_to_csv=os.path.join(dc_data_dir,"trained_models",network_name,"analysis/train/data.csv")
85+
fig_axes=DCEP.run_on_single_dataframe(path_to_csv,label=network_name,previous_fig_axes=fig_axes,save=False)
86+
87+
plt.savefig("Training.png")
88+
89+
90+
path_to_csv=os.path.join(dc_data_dir,"trained_models",network_name,"analysis/test/data.csv")
91+
fig_axes=DCEP.run_on_single_dataframe(path_to_csv,label=network_name,save=False)
92+
93+
path_to_csv=os.path.join(dc_data_dir,"trained_models",network_name,"analysis/test/data.csv")
94+
fig_axes=DCEP.run_on_single_dataframe(path_to_csv,label=network_name,previous_fig_axes=fig_axes,save=False)
95+
96+
plt.savefig("Test.png")
97+
98+
99+
path_to_csv=os.path.join(dc_data_dir,"trained_models",network_name,"analysis/cross_scene/data.csv")
100+
fig_axes=DCEP.run_on_single_dataframe(path_to_csv,label=network_name,save=False)
101+
102+
path_to_csv=os.path.join(dc_data_dir,"trained_models",network_name,"analysis/cross_scene/data.csv")
103+
fig_axes=DCEP.run_on_single_dataframe(path_to_csv,label=network_name,previous_fig_axes=fig_axes,save=False)
104+
105+
plt.savefig("CrossScene.png")
106+
107+
108+
109+
110+
config_filename=os.path.join(utils.getDenseCorrespondenceSourceDir(),'config',
111+
'dense_correspondence','evaluation','evaluation.yaml')
112+
config=utils.getDictFromYamlFilename(config_filename)
113+
default_config=utils.get_defaults_config()
114+
115+
# utils.set_cuda_visible_devices([0])
116+
dce=DenseCorrespondenceEvaluation(config)
117+
DCE=DenseCorrespondenceEvaluation
118+
119+
network_name="caterpillar_3"
120+
dcn=dce.load_network_from_config(network_name)
121+
dataset=dcn.load_training_dataset()
122+
DenseCorrespondenceEvaluation.evaluate_network_qualitative(dcn,dataset=dataset,randomize=True)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp