Skip to content

Commit aafee15

Browse files
committed
refactor: add user-defined url in config, add docs
1 parent 0c1a69b commit aafee15

File tree

8 files changed

+34
-45
lines changed

8 files changed

+34
-45
lines changed

backend/README.md

+21-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
# 백엔드
2+
fakebusters에서 제공하는 4가지 모델의 시연을 위한 데모페이지의 백엔드 코드
23

3-
`cd backend/dbust-backend-fastapi`
4+
fastapi, uvicorn 사용
45

5-
`pip install -r requirements.txt`
6+
### 최소 스펙
7+
v2 CPU, 16GB RAM (동영상 처리를 위함)
68

7-
`uvicorn main:app --reload`
9+
### 백엔드 실행
10+
1. config.py 설정
11+
- 각 모델 서버의 url 설정 필요
12+
- 각 모델 서버가 실행되고 있지 않으면, 프론트에 404 응답이 반한됨
13+
14+
2. 실행 환경 설정
15+
프로젝트 전체 최상단 폴더에 위치한 setup.sh 로 backend conda 가상환경 실행이 필요함
16+
```bash
17+
conda activate backend
18+
```
19+
20+
3. 백엔드 코드 실행
21+
```bash
22+
cd dbust-backend-fastapi
23+
uvicorn main:app --reload #localhost, 8000으로 실행
24+
uvicorn main:app --host 0.0.0.0 --port 8000 #호스트와 포트 지정해 실행
25+
```

backend/dbust-backend-fastapi/__init__.py

Whitespace-only changes.

backend/dbust-backend-fastapi/config.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@
77
AWS_SECRET_KEY = os.getenv("AWS_SECRET_KEY")
88
BUCKET_NAME = "fakebuster"
99
REGION = "ap-northeast-2"
10-
CSV_FILE_PATH = "upload_metrics.csv"
10+
CSV_FILE_PATH = "upload_metrics.csv"
11+
12+
lipforensics_server_url = "localhost:8000/upload-video/"
13+
mmnet_server_url = "localhost:8001/process_video/"
14+
fakecatcher_cnn_server_url = "localhost:8002/upload-video/"
15+
fakecatcher_feature_server_url = "localhost:8003/upload-video/"
-187 KB
Binary file not shown.

backend/dbust-backend-fastapi/requirements.txt

-39
This file was deleted.

backend/dbust-backend-fastapi/routers/__init__.py

Whitespace-only changes.

backend/dbust-backend-fastapi/routers/simulate_model_sever.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from fastapi import APIRouter, HTTPException, File, UploadFile
22
from fastapi.responses import StreamingResponse, JSONResponse
3+
from dbust_backend_fastapi.config import lipforensic_server_url, mmnet_server_url, fakecatcher_cnn_server_url, fakecatcher_feature_server_url
34
import random
45
import httpx
56
import os, shutil
@@ -63,7 +64,8 @@ async def roi_model(file: UploadFile = File(...)):
6364

6465
video_file = open(file_path, "rb")
6566

66-
model_server_url = "https://358e-165-132-46-83.ngrok-free.app/upload-video/"
67+
model_server_url = "https://358e-165-132-46-83.ngrok-free.app/upload-video/" #can be hardcoded
68+
model_server_url = lipforensic_server_url
6769

6870
try:
6971
async with httpx.AsyncClient(timeout=60.0) as client:
@@ -89,8 +91,8 @@ async def model(file: UploadFile = File(...)):
8991
Output: response: dict {message (text), status (text), reults (float)}
9092
'''
9193

92-
model_sever_url = "http://165.132.46.87:32116/process_video/"
9394
model_server_url = "https://9d4f-165-132-46-93.ngrok-free.app/process_video/"
95+
model_server_url = mmnet_server_url
9496

9597
file_path = os.path.join(VIDEO_DIR, file.filename)
9698
with open(file_path, "wb") as buffer:
@@ -170,6 +172,7 @@ def video_iterator(file):
170172
@router.post("/fakecatcher-cnn")
171173
async def get_result(file: UploadFile = File(...)):
172174
model_server_url = "https://534e-165-132-46-85.ngrok-free.app/upload-video/"
175+
model_server_url = fakecatcher_cnn_server_url
173176
file_path = os.path.join(VIDEO_DIR, file.filename)
174177

175178
with open(file_path, "wb") as buffer:
@@ -197,6 +200,8 @@ async def get_result(file: UploadFile = File(...)):
197200
@router.post("/fakecatcher-feature")
198201
async def get_result(file: UploadFile = File(...)):
199202
model_server_url = "https://be4e-165-132-46-92.ngrok-free.app/upload-video"
203+
model_server_url = fakecatcher_feature_server_url
204+
200205
file_path = os.path.join(VIDEO_DIR, file.filename)
201206

202207
with open(file_path, "wb") as buffer:

0 commit comments

Comments
 (0)