LapStore commited on
Commit
8791de8
·
1 Parent(s): 1976616

modified back image STEP 2

Browse files
Files changed (2) hide show
  1. app.py +14 -2
  2. index.html +2 -1
app.py CHANGED
@@ -63,14 +63,26 @@ async def image_step1(image_file: UploadFile = File(...),background_image: Optio
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
 
68
  contents = await image_file.read()
69
  image = Image.open(io.BytesIO(contents))
70
 
71
  things_replace=ast.literal_eval(things_replace)
 
72
 
73
- produced_image=SegmenterBackground().Back_step2(image,"cam",things_replace,int(blur_radius))
 
 
 
 
 
 
 
 
 
 
74
 
75
  # Save the processed image to a temporary file
76
  output_file_path_tmp = "/tmp/tmp_processed_image.png"
 
63
 
64
 
65
  @app.post('/imageStep2')
66
+ async def image_step2(image_file: UploadFile = File(...),background_image: Optional [UploadFile] = File(None),type_of_filters: str = Form(...),
67
+ things_replace: str = Form(...), blur_radius: str = Form(...)):#--->,background_image: UploadFile = File(...)):
68
 
69
  contents = await image_file.read()
70
  image = Image.open(io.BytesIO(contents))
71
 
72
  things_replace=ast.literal_eval(things_replace)
73
+ blur_radius=int(blur_radius)
74
 
75
+ input_to_type_of_filters=None
76
+
77
+ if background_image and background_image.filename:
78
+ contents__back = await background_image.read()
79
+ image_back = Image.open(io.BytesIO(contents__back))
80
+ input_to_type_of_filters = image_back
81
+ else:
82
+ input_to_type_of_filters = type_of_filters
83
+
84
+
85
+ produced_image=SegmenterBackground().Back_step2(image,input_to_type_of_filters,things_replace,int(blur_radius))
86
 
87
  # Save the processed image to a temporary file
88
  output_file_path_tmp = "/tmp/tmp_processed_image.png"
index.html CHANGED
@@ -2,9 +2,10 @@
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
  type_of_filters :<p><input type="text" name="type_of_filters" /></p><br>
 
8
  blur_radius :<p><input type="text" name="blur_radius" /></p><br>
9
  Image : <input type="file" name="image_file" required><br><br>
10
  Background_Image : <input type="file" name="background_image" ><br><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
  type_of_filters :<p><input type="text" name="type_of_filters" /></p><br>
8
+ things_replace :<p><input type="text" name="things_replace" /></p><br>
9
  blur_radius :<p><input type="text" name="blur_radius" /></p><br>
10
  Image : <input type="file" name="image_file" required><br><br>
11
  Background_Image : <input type="file" name="background_image" ><br><br>