Skip to content

Commit 56ecc38

Browse files
mihaelacr-googlediegolascasas
authored andcommitted
Update scratchgan and cs_gan run code to fix python and pip versions.
PiperOrigin-RevId: 339116353
1 parent 7488a1f commit 56ecc38

File tree

3 files changed

+78
-36
lines changed

3 files changed

+78
-36
lines changed

Diff for: cs_gan/run.sh

+25-5
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,32 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
16-
python3 -m venv cs_gan_venv
15+
# Install python3.5
16+
which python3.5
17+
if [ $? -eq 1 ]; then
18+
echo 'Installing python3.5'
19+
(cd /usr/src/
20+
sudo wget https://www.python.org/ftp/python/3.5.6/Python-3.5.6.tgz
21+
tar -xvzf Python-3.5.6.tgz
22+
sudo tar -xvzf Python-3.5.6.tgz
23+
cd Python-3.5.6
24+
./configure --enable-loadable-sqlite-extensions --enable-optimizations
25+
sudo make altinstall)
26+
fi
27+
# Fail on any error.
28+
set -e
29+
python3.5 -m venv cs_gan_venv
30+
echo 'Created venv'
1731
source cs_gan_venv/bin/activate
18-
pip install --upgrade pip
32+
echo 'Installing pip'
33+
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
34+
python3.5 get-pip.py pip==20.2.3
35+
36+
echo 'Getting requirements.'
1937
pip install -r cs_gan/requirements.txt
2038

21-
python -m cs_gan.main_cs
2239

23-
python -m cs_gan.main
40+
echo 'Starting training...'
41+
python3.5 -m cs_gan.main_cs
42+
# Gan code.
43+
python3.5 -m cs_gan.main

Diff for: scratchgan/README.md

+1-31
Original file line numberDiff line numberDiff line change
@@ -39,34 +39,4 @@ The data contains:
3939

4040
## Running
4141

42-
Download the data and place it in the directory specified by `data_dir` flag:
43-
44-
mkdir -p /tmp/emnlp2017
45-
curl https://storage.googleapis.com/deepmind-scratchgan-data/train.json --output /tmp/emnlp2017/train.json
46-
curl https://storage.googleapis.com/deepmind-scratchgan-data/valid.json --output /tmp/emnlp2017/valid.json
47-
curl https://storage.googleapis.com/deepmind-scratchgan-data/test.json --output /tmp/emnlp2017/test.json
48-
curl https://storage.googleapis.com/deepmind-scratchgan-data/glove_emnlp2017.txt --output /tmp/emnlp2017/glove_emnlp2017.txt
49-
50-
Create and activate a virtual environment if needed:
51-
52-
virtualenv scratchgan-venv
53-
source scratchgan-venv/bin/activate
54-
55-
56-
Note: the code uses python 2. This might mean that to create the virtual env
57-
you have to pass a path to the python binary to be used, as follows:
58-
`virtualenv -p /usr/bin/python2.7 scratchgan-venv`.
59-
60-
Install requirements:
61-
62-
pip install -r scratchgan/requirements.txt
63-
64-
Run training and evaluation jobs:
65-
66-
python2 -m scratchgan.experiment --mode="train" &
67-
python2 -m scratchgan.experiment --mode="evaluate_pair" &
68-
69-
The evaluation code is designed to run in parallel with the training.
70-
71-
The training code saves checkpoints periodically, the evaluation code
72-
looks for new checkpoints and evaluate them.
42+
./scratchgan/run.sh

Diff for: scratchgan/run.sh

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/sh
2+
# Copyright 2019 Deepmind Technologies Limited.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
17+
# Get EMNLP data.
18+
mkdir -p /tmp/emnlp2017
19+
curl https://storage.googleapis.com/deepmind-scratchgan-data/train.json --output /tmp/emnlp2017/train.json
20+
curl https://storage.googleapis.com/deepmind-scratchgan-data/valid.json --output /tmp/emnlp2017/valid.json
21+
curl https://storage.googleapis.com/deepmind-scratchgan-data/test.json --output /tmp/emnlp2017/test.json
22+
curl https://storage.googleapis.com/deepmind-scratchgan-data/glove_emnlp2017.txt --output /tmp/emnlp2017/glove_emnlp2017.txt
23+
24+
25+
# Install python3.5
26+
which python3.5
27+
if [ $? -eq 1 ]; then
28+
echo 'Installing python3.5'
29+
(cd /usr/src/
30+
sudo wget https://www.python.org/ftp/python/3.5.6/Python-3.5.6.tgz
31+
tar -xvzf Python-3.5.6.tgz
32+
sudo tar -xvzf Python-3.5.6.tgz
33+
cd Python-3.5.6
34+
./configure --enable-loadable-sqlite-extensions --enable-optimizations
35+
sudo make altinstall)
36+
fi
37+
# Fail on any error.
38+
set -e
39+
python3.5 -m venv scratchgan-venv
40+
echo 'Created venv'
41+
source scratchgan-venv/bin/activate
42+
echo 'Installing pip'
43+
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
44+
python3.5 get-pip.py pip==20.2.3
45+
46+
47+
echo 'Getting requirements.'
48+
pip install -r scratchgan/requirements.txt
49+
50+
echo 'Starting training...'
51+
python3.5 -m scratchgan.experiment --mode="train" &
52+
python3.5 -m scratchgan.experiment --mode="evaluate_pair" &

0 commit comments

Comments
 (0)