-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
31 lines (23 loc) · 846 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import shutil
import urllib.request
from fastapi import FastAPI, UploadFile, File
from checking_yolo5 import DetectObject
app = FastAPI()
@app.post("/upload_file/")
async def create_upload_file(file: UploadFile = File(...)):
detect = DetectObject()
path = file.filename
with open(f'{path}', "wb") as buffer:
shutil.copyfileobj(file.file, buffer)
images = detect.video_to_images(file.filename)
result = detect.detect_objects(images)
return result
@app.post("/link_upload_file/")
def upload_file():
detect = DetectObject()
file_name = 'trial_video.mp4'
dwn_link = "https://www.youtube.com/watch?v=Glk4det3JFE&ab_channel=AlphaCreations"
urllib.request.urlretrieve(dwn_link, file_name)
images = detect.video_to_images(file_name)
result = detect.detect_objects(images)
return result