Spaces:
Sleeping
Sleeping
rogerxavier
commited on
Commit
•
28a8a5f
1
Parent(s):
89ea09f
Update app.py
Browse files
app.py
CHANGED
@@ -1,43 +1,57 @@
|
|
1 |
from typing import List
|
2 |
from pydantic import BaseModel
|
3 |
-
from lama_cleaner.server import
|
|
|
|
|
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 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from typing import List
|
2 |
from pydantic import BaseModel
|
3 |
+
from lama_cleaner.server import process
|
4 |
+
import uvicorn
|
5 |
+
from fastapi import FastAPI
|
6 |
|
7 |
+
@app.on_event("startup")
|
8 |
+
async def app_start():
|
9 |
+
image_bytes = open('image.jpg', 'rb')
|
10 |
+
mask_bytes = open('mask.jpg', 'rb')
|
11 |
+
# 将字节数据转换为Base64编码的字符串
|
12 |
+
|
13 |
+
files = {
|
14 |
+
"image": image_bytes,
|
15 |
+
"mask":mask_bytes
|
16 |
+
}
|
17 |
+
payload = {
|
18 |
+
"ldmSteps": 25,
|
19 |
+
"ldmSampler": "plms",
|
20 |
+
"zitsWireframe": True,
|
21 |
+
"hdStrategy": "Crop",
|
22 |
+
"hdStrategyCropMargin": 196,
|
23 |
+
"hdStrategyCropTrigerSize": 800,
|
24 |
+
"hdStrategyResizeLimit": 2048,
|
25 |
+
"prompt": "",
|
26 |
+
"negativePrompt": "",
|
27 |
+
"croperX": 307,
|
28 |
+
"croperY": 544,
|
29 |
+
"croperHeight": 512,
|
30 |
+
"croperWidth": 512,
|
31 |
+
"useCroper": False,
|
32 |
+
"sdMaskBlur": 5,
|
33 |
+
"sdStrength": 0.75,
|
34 |
+
"sdSteps": 50,
|
35 |
+
"sdGuidanceScale": 7.5,
|
36 |
+
"sdSampler": "uni_pc",
|
37 |
+
"sdSeed": -1,
|
38 |
+
"sdMatchHistograms": False,
|
39 |
+
"sdScale": 1,
|
40 |
+
"cv2Radius": 5,
|
41 |
+
"cv2Flag": "INPAINT_NS",
|
42 |
+
"paintByExampleSteps": 50,
|
43 |
+
"paintByExampleGuidanceScale": 7.5,
|
44 |
+
"paintByExampleSeed": -1,
|
45 |
+
"paintByExampleMaskBlur": 5,
|
46 |
+
"paintByExampleMatchHistograms": False,
|
47 |
+
"p2pSteps": 50,
|
48 |
+
"p2pImageGuidanceScale": 1.5,
|
49 |
+
"p2pGuidanceScale": 7.5,
|
50 |
+
"controlnet_conditioning_scale": 0.4,
|
51 |
+
"controlnet_method": "control_v11p_sd15_canny"
|
52 |
+
}#payload用data
|
53 |
+
|
54 |
+
resp = process(files=files,payload=payload)
|
55 |
+
print(resp)
|
56 |
+
if __name__ == '__main__':
|
57 |
+
uvicorn.run(app, host='0.0.0.0', port=7860)
|