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

*): Make code run on python3. #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bash launch/run_train.sh
```
To test:
```
python test --input_path path/to/img
python test.py --input_path path/to/img
```

## Citation
Expand Down
8 changes: 4 additions & 4 deletions data/dataset_aus.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def __getitem__(self, index):
real_cond = self._get_cond_by_id(sample_id)

if real_img is None:
print 'error reading image %s, skipping sample' % sample_id
print('error reading image %s, skipping sample' % sample_id)
if real_cond is None:
print 'error reading aus %s, skipping sample' % sample_id
print('error reading aus %s, skipping sample' % sample_id)

desired_cond = self._generate_random_cond()

Expand Down Expand Up @@ -92,11 +92,11 @@ def _create_transform(self):

def _read_ids(self, file_path):
ids = np.loadtxt(file_path, delimiter='\t', dtype=np.str)
return [id[:-4] for id in ids]
return [str.encode(id[:-4]) for id in ids]

def _read_conds(self, file_path):
with open(file_path, 'rb') as f:
return pickle.load(f)
return pickle.load(f, encoding='bytes')

def _get_cond_by_id(self, id):
if id in self._conds:
Expand Down
2 changes: 1 addition & 1 deletion launch/run_train.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

python train.py \
--data_dir path/to/dataset/ \
--data_dir sample_dataset \
--name experiment_1 \
--batch_size 25 \
6 changes: 3 additions & 3 deletions models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ def _load_optimizer(self, optimizer, optimizer_label, epoch_label):
load_path), 'Weights file not found. Have you trained a model!? We are not providing one' % load_path

optimizer.load_state_dict(torch.load(load_path))
print 'loaded optimizer: %s' % load_path
print('loaded optimizer: %s' % load_path)

def _save_network(self, network, network_label, epoch_label):
save_filename = 'net_epoch_%s_id_%s.pth' % (epoch_label, network_label)
save_path = os.path.join(self._save_dir, save_filename)
torch.save(network.state_dict(), save_path)
print 'saved net: %s' % save_path
print('saved net: %s' % save_path)

def _load_network(self, network, network_label, epoch_label):
load_filename = 'net_epoch_%s_id_%s.pth' % (epoch_label, network_label)
Expand All @@ -105,7 +105,7 @@ def _load_network(self, network, network_label, epoch_label):
load_path), 'Weights file not found. Have you trained a model!? We are not providing one' % load_path

network.load_state_dict(torch.load(load_path))
print 'loaded net: %s' % load_path
print('loaded net: %s' % load_path)

def update_learning_rate(self):
pass
Expand Down
2 changes: 1 addition & 1 deletion networks/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_by_name(network_name, *args, **kwargs):
else:
raise ValueError("Network %s not recognized." % network_name)

print "Network %s was created" % network_name
print("Network %s was created" % network_name)

return network

Expand Down