LapStore commited on
Commit ·
29dc177
1
Parent(s): 5d29343
try space
Browse files- app.py +1 -20
- index.html +3 -3
app.py
CHANGED
|
@@ -8,6 +8,7 @@ import matplotlib.pyplot as plt
|
|
| 8 |
import numpy as np
|
| 9 |
import ast
|
| 10 |
from server import *
|
|
|
|
| 11 |
|
| 12 |
#http://localhost:8000
|
| 13 |
app = FastAPI()
|
|
@@ -65,23 +66,3 @@ async def Video(video_file: UploadFile = File(...),kind_back: str = Form(...), b
|
|
| 65 |
return StreamingResponse(open('tmp/29_sep_2.avi', "rb"), media_type="video/mp4")
|
| 66 |
|
| 67 |
|
| 68 |
-
|
| 69 |
-
@app.post('/predict')
|
| 70 |
-
async def predict(supported_types_str: str = Form(),age: str = Form() , file: UploadFile = File(...)):
|
| 71 |
-
# Form(...) to accept input as web form ,may change when android /upload
|
| 72 |
-
|
| 73 |
-
supported_types=ast.literal_eval(supported_types_str)
|
| 74 |
-
|
| 75 |
-
contents = await file.read()
|
| 76 |
-
image = Image.open(io.BytesIO(contents))
|
| 77 |
-
|
| 78 |
-
# Process the image (example: convert to grayscale)
|
| 79 |
-
processed_image = image.convert("L")
|
| 80 |
-
|
| 81 |
-
# Save the processed image to a temporary file
|
| 82 |
-
output_file_path = "/tmp/tmp_processed_image.png"
|
| 83 |
-
processed_image.save(output_file_path)
|
| 84 |
-
|
| 85 |
-
# Return the processed image for download
|
| 86 |
-
return FileResponse(output_file_path, media_type='image/png', filename="/tmp/tmp_processed_image.png")
|
| 87 |
-
|
|
|
|
| 8 |
import numpy as np
|
| 9 |
import ast
|
| 10 |
from server import *
|
| 11 |
+
import cv2
|
| 12 |
|
| 13 |
#http://localhost:8000
|
| 14 |
app = FastAPI()
|
|
|
|
| 66 |
return StreamingResponse(open('tmp/29_sep_2.avi', "rb"), media_type="video/mp4")
|
| 67 |
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
index.html
CHANGED
|
@@ -2,11 +2,11 @@
|
|
| 2 |
<body bgcolor="#00cccc">
|
| 3 |
<center>
|
| 4 |
<br><br><br>
|
| 5 |
-
<form action="https://taha454-backg.hf.space/
|
| 6 |
<p><h3>Enter Image:</h3></p>
|
| 7 |
-
Name :<p><input type="text" name="
|
| 8 |
blur_radius :<p><input type="text" name="blur_radius" /></p><br>
|
| 9 |
-
|
| 10 |
<p><input type="submit" value="submit" /></p>
|
| 11 |
</form>
|
| 12 |
</center>
|
|
|
|
| 2 |
<body bgcolor="#00cccc">
|
| 3 |
<center>
|
| 4 |
<br><br><br>
|
| 5 |
+
<form action="https://taha454-backg.hf.space/Video" method="post" enctype="multipart/form-data">
|
| 6 |
<p><h3>Enter Image:</h3></p>
|
| 7 |
+
Name :<p><input type="text" name="kind_back" /></p><br>
|
| 8 |
blur_radius :<p><input type="text" name="blur_radius" /></p><br>
|
| 9 |
+
Video : <input type="file" name="video_file" required><br><br>
|
| 10 |
<p><input type="submit" value="submit" /></p>
|
| 11 |
</form>
|
| 12 |
</center>
|