(file: UploadFile = File(...))
| 65 | |
| 66 | @app.post("/yolo") |
| 67 | def process_yolov5(file: UploadFile = File(...)): |
| 68 | file_bytes = file.file.read() |
| 69 | image = Image.open(io.BytesIO(file_bytes)) |
| 70 | name = f"/data/{str(uuid.uuid4())}.png" |
| 71 | |
| 72 | # image.save(name) |
| 73 | image.filename = name |
| 74 | classes, converted_img = yolov5(image) |
| 75 | |
| 76 | bytes_io = io.BytesIO() |
| 77 | converted_img.save(name) |
| 78 | converted_img.save(bytes_io, format="PNG") |
| 79 | return Response(bytes_io.getvalue(), media_type="image/png") |
| 80 | |
| 81 | |
| 82 | @app.websocket("/yolo_ws/{client_id}") |