diff --git a/README.md b/README.md index d7dbc88..8381567 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,15 @@ 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: * Install a PostgreSQL server ### Launch the GAN server + ```bash cd gan_server # Install dependencies @@ -21,18 +25,22 @@ 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 @@ -45,6 +53,7 @@ node updatecache.js # And go... node server.js ``` + Your frontend is available at http://localhost:8888/ ### docker-compose setup @@ -52,17 +61,22 @@ Your frontend is available at http://localhost:8888/ 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 ``` diff --git a/gan_server/Dockerfile b/gan_server/Dockerfile index 35009fd..6663c84 100644 --- a/gan_server/Dockerfile +++ b/gan_server/Dockerfile @@ -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"] \ No newline at end of file diff --git a/gan_server/requirements.txt b/gan_server/requirements.txt index 830db9a..00d9fdf 100644 --- a/gan_server/requirements.txt +++ b/gan_server/requirements.txt @@ -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 \ No newline at end of file diff --git a/gan_server/server.py b/gan_server/server.py index 00d7e56..6fe13b9 100644 --- a/gan_server/server.py +++ b/gan_server/server.py @@ -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) @@ -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): @@ -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) +