LapStore
commited on
Commit
·
1976616
1
Parent(s):
3fca0b4
modified back mGE STEP 1
Browse files
app.py
CHANGED
@@ -19,7 +19,7 @@ app = FastAPI()
|
|
19 |
# Root route
|
20 |
@app.get('/')
|
21 |
def main():
|
22 |
-
return "Hello
|
23 |
|
24 |
##### use space /tmp/ ...
|
25 |
|
@@ -42,14 +42,13 @@ async def image_step1(image_file: UploadFile = File(...),background_image: Optio
|
|
42 |
|
43 |
output_step1=SegmenterBackground().Back_step1(image,input_to_type_of_filters,int(blur_radius))
|
44 |
produced_image=output_step1[0]
|
45 |
-
|
|
|
46 |
# Save the processed image to a temporary file
|
47 |
#output_file_path_tmp = "/tmp/tmp_processed_image.png"
|
48 |
#produced_image.save(output_file_path_tmp)
|
49 |
-
|
50 |
-
# Return the processed image for download
|
51 |
# return FileResponse(output_file_path_tmp, media_type='image/png', filename="/tmp/tmp_processed_image.png")
|
52 |
-
|
53 |
|
54 |
# Convert the image to base64 to return it in the response
|
55 |
buffered = io.BytesIO()
|
@@ -58,20 +57,11 @@ async def image_step1(image_file: UploadFile = File(...),background_image: Optio
|
|
58 |
|
59 |
# Returning both text and the base64 image
|
60 |
return {
|
61 |
-
"
|
62 |
-
"message": "Image processed successfully",
|
63 |
"image_base64": encoded_img
|
64 |
}
|
65 |
|
66 |
-
|
67 |
-
buffer = io.BytesIO()
|
68 |
-
produced_image.save(buffer, format="PNG")
|
69 |
-
buffer.seek(0)
|
70 |
-
return StreamingResponse(
|
71 |
-
buffer, media_type="image/png",
|
72 |
-
headers={"Content-Disposition": "attachment; filename=processed_image.png"}
|
73 |
-
)
|
74 |
-
'''
|
75 |
@app.post('/imageStep2')
|
76 |
async def image_step2(image_file: UploadFile = File(...),things_replace: str = Form(...), blur_radius: str = Form(...)):#--->,background_image: UploadFile = File(...)):
|
77 |
|
|
|
19 |
# Root route
|
20 |
@app.get('/')
|
21 |
def main():
|
22 |
+
return "Hello From Background remover !"
|
23 |
|
24 |
##### use space /tmp/ ...
|
25 |
|
|
|
42 |
|
43 |
output_step1=SegmenterBackground().Back_step1(image,input_to_type_of_filters,int(blur_radius))
|
44 |
produced_image=output_step1[0]
|
45 |
+
|
46 |
+
'''
|
47 |
# Save the processed image to a temporary file
|
48 |
#output_file_path_tmp = "/tmp/tmp_processed_image.png"
|
49 |
#produced_image.save(output_file_path_tmp)
|
|
|
|
|
50 |
# return FileResponse(output_file_path_tmp, media_type='image/png', filename="/tmp/tmp_processed_image.png")
|
51 |
+
'''
|
52 |
|
53 |
# Convert the image to base64 to return it in the response
|
54 |
buffered = io.BytesIO()
|
|
|
57 |
|
58 |
# Returning both text and the base64 image
|
59 |
return {
|
60 |
+
"message": output_step1[1],
|
|
|
61 |
"image_base64": encoded_img
|
62 |
}
|
63 |
|
64 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
@app.post('/imageStep2')
|
66 |
async def image_step2(image_file: UploadFile = File(...),things_replace: str = Form(...), blur_radius: str = Form(...)):#--->,background_image: UploadFile = File(...)):
|
67 |
|