Spaces:
Runtime error
Runtime error
File size: 938 Bytes
37e7800 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
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)
|