Kurumi commited on
Commit ·
09fee18
1
Parent(s): 62d4cc8
fix: missing torch
Browse files- app.py +9 -5
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
from flask import (
|
| 2 |
Flask,
|
| 3 |
jsonify,
|
|
@@ -5,8 +6,7 @@ from flask import (
|
|
| 5 |
send_file,
|
| 6 |
)
|
| 7 |
from io import BytesIO
|
| 8 |
-
from
|
| 9 |
-
|
| 10 |
|
| 11 |
app = Flask("ImageAPI")
|
| 12 |
|
|
@@ -17,11 +17,15 @@ def main():
|
|
| 17 |
|
| 18 |
if not prompt:
|
| 19 |
return jsonify({
|
| 20 |
-
"status":
|
| 21 |
-
"message": "
|
| 22 |
})
|
| 23 |
|
| 24 |
-
pipeline = AutoPipelineForText2Image.from_pretrained(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
pipeline.to("cuda")
|
| 26 |
|
| 27 |
image = pipeline(
|
|
|
|
| 1 |
+
from diffusers import AutoPipelineForText2Image
|
| 2 |
from flask import (
|
| 3 |
Flask,
|
| 4 |
jsonify,
|
|
|
|
| 6 |
send_file,
|
| 7 |
)
|
| 8 |
from io import BytesIO
|
| 9 |
+
from torch import float16
|
|
|
|
| 10 |
|
| 11 |
app = Flask("ImageAPI")
|
| 12 |
|
|
|
|
| 17 |
|
| 18 |
if not prompt:
|
| 19 |
return jsonify({
|
| 20 |
+
"status": 200,
|
| 21 |
+
"message": "API is Alive!",
|
| 22 |
})
|
| 23 |
|
| 24 |
+
pipeline = AutoPipelineForText2Image.from_pretrained(
|
| 25 |
+
pretrained_model_or_path="Lykon/DreamShaper",
|
| 26 |
+
torch_dtype=float16,
|
| 27 |
+
variant="fp16",
|
| 28 |
+
)
|
| 29 |
pipeline.to("cuda")
|
| 30 |
|
| 31 |
image = pipeline(
|
requirements.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
diffusers
|
| 2 |
flask
|
| 3 |
gevent
|
| 4 |
-
gunicorn
|
|
|
|
|
|
| 1 |
diffusers
|
| 2 |
flask
|
| 3 |
gevent
|
| 4 |
+
gunicorn
|
| 5 |
+
torch
|