Spaces:
Runtime error
Runtime error
add
Browse files
main.py
CHANGED
|
@@ -12,6 +12,8 @@ from utils import replace_background
|
|
| 12 |
from diffusers.utils import load_image
|
| 13 |
import base64
|
| 14 |
import io
|
|
|
|
|
|
|
| 15 |
app = FastAPI(name="mutilParam")
|
| 16 |
pipeline = get_pipeline()
|
| 17 |
|
|
@@ -27,18 +29,19 @@ async def predict(prompt=Body(...),imgbase64data=Body(...)):
|
|
| 27 |
start = time.time()
|
| 28 |
print("参数",imgbase64data,prompt)
|
| 29 |
image_data = base64.b64decode(imgbase64data)
|
| 30 |
-
print("本地图:", image_data)
|
| 31 |
image1 = Image.open(io.BytesIO(image_data))
|
| 32 |
w, h = image1.size
|
| 33 |
-
newW =
|
| 34 |
newH = int(h * newW / w)
|
| 35 |
img = image1.resize((newW, newH))
|
| 36 |
end1 = time.time()
|
|
|
|
|
|
|
| 37 |
print("图像:", img.size)
|
| 38 |
print("加载管道:", end1 - start)
|
| 39 |
result = pipeline(
|
| 40 |
prompt=prompt,
|
| 41 |
-
image=
|
| 42 |
strength=0.6,
|
| 43 |
seed=10,
|
| 44 |
width=256,
|
|
|
|
| 12 |
from diffusers.utils import load_image
|
| 13 |
import base64
|
| 14 |
import io
|
| 15 |
+
from datetime import datetime
|
| 16 |
+
|
| 17 |
app = FastAPI(name="mutilParam")
|
| 18 |
pipeline = get_pipeline()
|
| 19 |
|
|
|
|
| 29 |
start = time.time()
|
| 30 |
print("参数",imgbase64data,prompt)
|
| 31 |
image_data = base64.b64decode(imgbase64data)
|
|
|
|
| 32 |
image1 = Image.open(io.BytesIO(image_data))
|
| 33 |
w, h = image1.size
|
| 34 |
+
newW = 256
|
| 35 |
newH = int(h * newW / w)
|
| 36 |
img = image1.resize((newW, newH))
|
| 37 |
end1 = time.time()
|
| 38 |
+
now = datetime.now()
|
| 39 |
+
print(now)
|
| 40 |
print("图像:", img.size)
|
| 41 |
print("加载管道:", end1 - start)
|
| 42 |
result = pipeline(
|
| 43 |
prompt=prompt,
|
| 44 |
+
image=image1,
|
| 45 |
strength=0.6,
|
| 46 |
seed=10,
|
| 47 |
width=256,
|