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

Updated for tensorflow 1 retro-compatibility #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 5 additions & 4 deletions gan_server/server.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import sys
import json
from flask import Flask, request, jsonify
from flask_cors import CORS, cross_origin
import time
import tensorflow as tf
import tensorflow.compat.v1 as tf
import tensorflow_hub as hub
import numpy as np
from scipy.stats import truncnorm
Expand All @@ -17,8 +16,10 @@
truncation = 0.5

tf.reset_default_graph()
tf.disable_eager_execution()
print('Loading BigGAN module from:', module_path)
module = hub.Module(module_path)
print('BigGAN module loaded')
inputs = {k: tf.placeholder(v.dtype, v.get_shape().as_list(), k)
for k, v in module.get_input_info_dict().items()}
output = module(inputs)
Expand All @@ -34,6 +35,7 @@

sess = tf.Session()
sess.run(initializer)
print('ready!')

def truncated_z_sample(batch_size):
values = truncnorm.rvs(-2, 2, size=(batch_size, dim_z), random_state=random_state)
Expand Down Expand Up @@ -120,7 +122,6 @@ def encode_img(arr):
return img_str

app = Flask(__name__, static_url_path='') #, static_folder='public', )
CORS(app)

@app.route('/')
def index():
Expand Down Expand Up @@ -186,4 +187,4 @@ def mix_images():
if __name__ == '__main__':
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)
app.run(host='0.0.0.0', debug=True, port=port)