LapStore commited on
Commit
7928acb
1 Parent(s): 7b7dd7f
Files changed (2) hide show
  1. app.py +19 -2
  2. index.html +1 -1
app.py CHANGED
@@ -22,12 +22,12 @@ def main():
22
 
23
 
24
  @app.post('/imageStep1')
25
- async def image_step1(image_file: UploadFile = File(...),type_of_filters: str = Form(...), blur_radius: str = Form(...),):
26
 
27
  contents = await image_file.read()
28
  image = Image.open(io.BytesIO(contents))
29
 
30
- produced_image=SegmenterBackground().Back_step1(image,type_of_filters,int(blur_radius))[0]
31
 
32
  # Save the processed image to a temporary file
33
  output_file_path_tmp = "/tmp/tmp_processed_image.png"
@@ -37,6 +37,23 @@ async def image_step1(image_file: UploadFile = File(...),type_of_filters: str =
37
  return FileResponse(output_file_path_tmp, media_type='image/png', filename="/tmp/tmp_processed_image.png")
38
 
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
 
42
 
 
22
 
23
 
24
  @app.post('/imageStep1')
25
+ async def image_step1(image_file: UploadFile = File(...),type_of_filters: str = Form(...), blur_radius: str = Form(...)):#--->,background_image: UploadFile = File(...)):
26
 
27
  contents = await image_file.read()
28
  image = Image.open(io.BytesIO(contents))
29
 
30
+ produced_image=SegmenterBackground().Back_step1(image,type_of_filters,int(blur_radius))[0]#---->
31
 
32
  # Save the processed image to a temporary file
33
  output_file_path_tmp = "/tmp/tmp_processed_image.png"
 
37
  return FileResponse(output_file_path_tmp, media_type='image/png', filename="/tmp/tmp_processed_image.png")
38
 
39
 
40
+ @app.post('/imageStep2')
41
+ async def image_step2(image_file: UploadFile = File(...),things_replace: str = Form(...), blur_radius: str = Form(...)):#--->,background_image: UploadFile = File(...)):
42
+
43
+ contents = await image_file.read()
44
+ image = Image.open(io.BytesIO(contents))
45
+
46
+ things_replace=ast.literal_eval(things_replace)
47
+
48
+ produced_image=SegmenterBackground().Back_step2(image,things_replace,int(blur_radius))
49
+
50
+ # Save the processed image to a temporary file
51
+ output_file_path_tmp = "/tmp/tmp_processed_image.png"
52
+ produced_image.save(output_file_path_tmp)
53
+
54
+ # Return the processed image for download
55
+ return FileResponse(output_file_path_tmp, media_type='image/png', filename="/tmp/tmp_processed_image.png")
56
+
57
 
58
 
59
 
index.html CHANGED
@@ -2,7 +2,7 @@
2
  <body bgcolor="#00cccc">
3
  <center>
4
  <br><br><br>
5
- <form action="https://taha454-backg.hf.space/imageStep1" method="post" enctype="multipart/form-data">
6
  <p><h3>Enter Image:</h3></p>
7
  Name :<p><input type="text" name="type_of_filters" /></p><br>
8
  blur_radius :<p><input type="text" name="blur_radius" /></p><br>
 
2
  <body bgcolor="#00cccc">
3
  <center>
4
  <br><br><br>
5
+ <form action="https://taha454-backg.hf.space/imageStep2" method="post" enctype="multipart/form-data">
6
  <p><h3>Enter Image:</h3></p>
7
  Name :<p><input type="text" name="type_of_filters" /></p><br>
8
  blur_radius :<p><input type="text" name="blur_radius" /></p><br>