Spaces:
Sleeping
Sleeping
imseldrith
commited on
Commit
•
6a53e9c
1
Parent(s):
4bb3f1f
Update test.py
Browse files
test.py
CHANGED
@@ -10,7 +10,7 @@ def index():
|
|
10 |
return render_template('index.html')
|
11 |
|
12 |
@app.route('/generate', methods=['POST'])
|
13 |
-
def generate_image():
|
14 |
prompt = request.form['prompt']
|
15 |
style = request.form['style']
|
16 |
ratio = request.form['ratio']
|
@@ -18,11 +18,11 @@ def generate_image():
|
|
18 |
imagine = AsyncImagine()
|
19 |
|
20 |
try:
|
21 |
-
img_data =
|
22 |
prompt=prompt,
|
23 |
style=Style[style],
|
24 |
ratio=Ratio[ratio]
|
25 |
-
)
|
26 |
except Exception as e:
|
27 |
return f"An error occurred while generating the image: {e}", 500
|
28 |
|
@@ -44,7 +44,7 @@ def generate_image():
|
|
44 |
return render_template('output.html')
|
45 |
|
46 |
@app.route('/api/generate', methods=['POST'])
|
47 |
-
def api_generate_image():
|
48 |
data = request.get_json()
|
49 |
prompt = data['prompt']
|
50 |
style = data['style']
|
@@ -53,11 +53,11 @@ def api_generate_image():
|
|
53 |
imagine = AsyncImagine()
|
54 |
|
55 |
try:
|
56 |
-
img_data =
|
57 |
prompt=prompt,
|
58 |
style=Style[style],
|
59 |
ratio=Ratio[ratio]
|
60 |
-
)
|
61 |
except Exception as e:
|
62 |
return jsonify({'error': f"An error occurred while generating the image: {e}"}), 500
|
63 |
|
@@ -80,4 +80,4 @@ def api_generate_image():
|
|
80 |
return send_file(image_path, mimetype='image/jpeg', as_attachment=True)
|
81 |
|
82 |
if __name__ == "__main__":
|
83 |
-
app.run(host="0.0.0.0", port=7860)
|
|
|
10 |
return render_template('index.html')
|
11 |
|
12 |
@app.route('/generate', methods=['POST'])
|
13 |
+
async def generate_image():
|
14 |
prompt = request.form['prompt']
|
15 |
style = request.form['style']
|
16 |
ratio = request.form['ratio']
|
|
|
18 |
imagine = AsyncImagine()
|
19 |
|
20 |
try:
|
21 |
+
img_data = await imagine.sdprem(
|
22 |
prompt=prompt,
|
23 |
style=Style[style],
|
24 |
ratio=Ratio[ratio]
|
25 |
+
)
|
26 |
except Exception as e:
|
27 |
return f"An error occurred while generating the image: {e}", 500
|
28 |
|
|
|
44 |
return render_template('output.html')
|
45 |
|
46 |
@app.route('/api/generate', methods=['POST'])
|
47 |
+
async def api_generate_image():
|
48 |
data = request.get_json()
|
49 |
prompt = data['prompt']
|
50 |
style = data['style']
|
|
|
53 |
imagine = AsyncImagine()
|
54 |
|
55 |
try:
|
56 |
+
img_data = await imagine.sdprem(
|
57 |
prompt=prompt,
|
58 |
style=Style[style],
|
59 |
ratio=Ratio[ratio]
|
60 |
+
)
|
61 |
except Exception as e:
|
62 |
return jsonify({'error': f"An error occurred while generating the image: {e}"}), 500
|
63 |
|
|
|
80 |
return send_file(image_path, mimetype='image/jpeg', as_attachment=True)
|
81 |
|
82 |
if __name__ == "__main__":
|
83 |
+
app.run(host="0.0.0.0", port=7860)
|