LapStore commited on
Commit
5d29343
1 Parent(s): 5e168b6
Files changed (2) hide show
  1. app.py +10 -2
  2. server.py +1 -1
app.py CHANGED
@@ -1,6 +1,5 @@
1
  from fastapi import FastAPI ,Request ,Form, UploadFile, File
2
- from fastapi.responses import JSONResponse
3
- from fastapi.responses import HTMLResponse, FileResponse
4
  import os
5
  import io
6
  from PIL import ImageOps,Image ,ImageFilter
@@ -55,6 +54,15 @@ async def image_step2(image_file: UploadFile = File(...),things_replace: str = F
55
  return FileResponse(output_file_path_tmp, media_type='image/png', filename="/tmp/tmp_processed_image.png")
56
 
57
 
 
 
 
 
 
 
 
 
 
58
 
59
 
60
 
 
1
  from fastapi import FastAPI ,Request ,Form, UploadFile, File
2
+ from fastapi.responses import HTMLResponse, FileResponse,StreamingResponse,JSONResponse
 
3
  import os
4
  import io
5
  from PIL import ImageOps,Image ,ImageFilter
 
54
  return FileResponse(output_file_path_tmp, media_type='image/png', filename="/tmp/tmp_processed_image.png")
55
 
56
 
57
+ @app.post('/Video')
58
+ async def Video(video_file: UploadFile = File(...),kind_back: str = Form(...), blur_radius: str = Form(...)):#--->,background_image: UploadFile = File(...)):
59
+ video_data = await video_file.read()
60
+ nparr = np.frombuffer(video_data, np.uint8)
61
+ video_path=cv2.imdecode(nparr, cv2.IMREAD_COLOR) #named this as just passed as it's path
62
+
63
+ produced_video=SegmenterBackground().Back_video(video_path, 'tmp/29_sep_2.avi','cam',['animal','person'])#video,background_image,what_remove,blur_radius=23)
64
+
65
+ return StreamingResponse(open('tmp/29_sep_2.avi', "rb"), media_type="video/mp4")
66
 
67
 
68
 
server.py CHANGED
@@ -149,7 +149,7 @@ class SegmenterBackground():
149
  return list_output
150
 
151
 
152
- def Back_video_step1(self,video_path,output_path,background_image,kind_back,blur_radius=35):#background_image,what_remove,blur_radius=23): # back_image and video? #what_remove if many person it is not identify so same
153
  cap = cv2.VideoCapture(video_path)
154
 
155
  # Get video properties
 
149
  return list_output
150
 
151
 
152
+ def Back_video(self,video_path,output_path,background_image,kind_back,blur_radius=35):#background_image,what_remove,blur_radius=23): # back_image and video? #what_remove if many person it is not identify so same
153
  cap = cv2.VideoCapture(video_path)
154
 
155
  # Get video properties