Ridasaba's picture
upload app.py
37e7800 verified
raw
history blame contribute delete
No virus
938 Bytes
from flask import Flask, request, jsonify, render_template
from PIL import Image
import requests
from io import BytesIO
import base64
app = Flask(__name__)
@app.route('/')
def home():
return render_template("index.html")
@app.route("/preds", methods=['POST'])
def submit():
cloth = request.files['cloth']
model = request.files['model']
## replace the url from the ngrok url provided on the notebook on server.
url = "https://5a37436f4b54b9c2cd.gradio.live"
print("sending")
response = requests.post(url=url, files={"cloth":cloth.stream, "model":model.stream})
op = Image.open(BytesIO(response.content))
buffer = BytesIO()
op.save(buffer, 'png')
buffer.seek(0)
data = buffer.read()
data = base64.b64encode(data).decode()
return render_template('index.html', op=data)
# return render_template('index.html', test=True)
if __name__ == '__main__':
app.run(debug=True)