Skip to content
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
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,38 @@ Pull request are more than welcome :)
## How to use

### Prerequisites

* Install Python 3 + pip (for the GAN server)
* Avoid [SSL: CERTIFICATE_VERIFY_FAILED] error by just browse to Applications/Python 3.X and double-click Install Certificates.command.
* Install NodeJS + npm (for the frontend)
* suggested node version : (v12.16.3) in order to avoid Timeout error, ref: <https://stackoverflow.com/questions/40435315/knex-timeout-acquiring-a-connection-the-pool-is-probably-full-are-you-missing>
* Install a PostgreSQL server

### Launch the GAN server

```bash
cd gan_server
# Install dependencies
pip install -r requirements.txt
# And go...
python server.py
```

Your GAN server is available at http://localhost:5000/

### Configure the frontend
For quick hacking, if you have Docker at your disposal, you can spawn a PostgreSQL database like so:

```bash
docker run -p 5432:5432 --name ganbreederpostgres -e POSTGRES_PASSWORD=ganbreederpostgres -d postgres
```

With that simple scenario, the database and user would be `postgres` and the password would be `ganbreederpostgres`

Copy the file `server/example_secrets.js` to `secrets.js` and modify it to fit your environment.

### Launch the frontend

```bash
cd server
npm install
Expand All @@ -45,24 +53,30 @@ node updatecache.js
# And go...
node server.js
```

Your frontend is available at http://localhost:8888/

### docker-compose setup

Make sure that [docker](https://docs.docker.com/install/) and [docker-compose](https://docs.docker.com/compose/install/) are installed.

Start the containers:

```bash
docker-compose up
```

Your frontend is available at http://localhost:8888/, backend at http://localhost:5000/.
Initial backend setup can take few minutes.

If this is the first time you are running the project you might want to generate some random images:

```bash
docker-compose exec server node make_randoms.js
```

Restart only frontend server (to avoid backend initialization wait):

```bash
docker-compose restart server
```
4 changes: 2 additions & 2 deletions gan_server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM python:3.6.9-buster
FROM python:3.9.1-buster
ADD ./gan_server /gan_server
WORKDIR /gan_server
# Install dependencies
RUN pip install -r /gan_server/requirements.txt
# And go...
CMD ["python", "server.py"]
CMD ["python", "server.py"]
8 changes: 4 additions & 4 deletions gan_server/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Flask==1.0.2
Flask-Cors==3.0.7
tensorflow==1.12.0
tensorflow_hub==0.2.0
scipy==1.1.0
Pillow==5.3.0
tensorflow==2.3.1
tensorflow_hub==0.10.0
scipy==1.4.1
Pillow==6.2.1
10 changes: 6 additions & 4 deletions gan_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
rand_seed = 123
truncation = 0.5

tf.reset_default_graph()
tf.compat.v1.disable_eager_execution()
tf.compat.v1.reset_default_graph()
print('Loading BigGAN module from:', module_path)
module = hub.Module(module_path)
inputs = {k: tf.placeholder(v.dtype, v.get_shape().as_list(), k)
inputs = {k: tf.compat.v1.placeholder(v.dtype, v.get_shape().as_list(), k)
for k, v in module.get_input_info_dict().items()}
output = module(inputs)

Expand All @@ -30,9 +31,9 @@
dim_z = input_z.shape.as_list()[1]
vocab_size = input_y.shape.as_list()[1]

initializer = tf.global_variables_initializer()
initializer = tf.compat.v1.global_variables_initializer()

sess = tf.Session()
sess = tf.compat.v1.Session()
sess.run(initializer)

def truncated_z_sample(batch_size):
Expand Down Expand Up @@ -187,3 +188,4 @@ def mix_images():
port = int(sys.argv[1]) if len(sys.argv) > 1 else 5000
print('port=', port)
app.run(host='0.0.0.0', debug=True, port=port)