-
Notifications
You must be signed in to change notification settings - Fork 1
Feat/video cutting #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| # api 範例: http://localhost:8000/processimg/?param1=./input_folder¶m2=./output_folder | ||
| @app.get("/processimg/") | ||
| def process_image(param1: str, param2: str): # 接受兩個參數,分別代表輸入圖片路徑跟輸出圖片路徑 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to review this now.
suggestion: Can we make it more scalable so we can process an image at a time and to prevent security issues with query params maybe we can use POST instead, thanks
| # api 範例: http://localhost:8000/processimg/?param1=./input_folder¶m2=./output_folder | |
| @app.get("/processimg/") | |
| def process_image(param1: str, param2: str): # 接受兩個參數,分別代表輸入圖片路徑跟輸出圖片路徑 | |
| # api 範例: http://localhost:8000/processimg | |
| @app.post("/processimg/") | |
| def process_image(req): | |
| input_image_path = body['input_img_path'] | |
| output_image_path = body['output_img_path'] |
again, sorry for the late review and not saying the requirements when you're implementing🙇♂️🙏
| #!/bin/bash | ||
|
|
||
| # 進入本專案所需環境 | ||
| conda activate /mnt/Nami/users/Jason0411202/anaconda3/envs/real3dportrait | ||
|
|
||
| # 執行 cutting_video.py 腳本 | ||
| python cutting_video.py | ||
|
|
||
| # 切換到 Real-ESRGAN 目錄 | ||
| cd Real-ESRGAN | ||
|
|
||
| # 執行 inference_realesrgan.py 腳本 | ||
| python inference_realesrgan.py -n RealESRGAN_x4plus -i inputs --face_enhance | ||
|
|
||
| # 返回上一層目錄 | ||
| cd .. | ||
|
|
||
| # 執行 scaling_video.py 腳本 | ||
| python scaling_video.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we have an api for this?
| return {"message": "Script executed successfully", "output": result.stdout.strip()} | ||
|
|
||
| except subprocess.CalledProcessError as e: | ||
| return {"message": "Script execution failed", "error": str(e), "stderr": e.stderr} |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Stack trace information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we should modify the code to log the detailed error information on the server and return a generic error message to the user. This approach ensures that sensitive information is not exposed to end users while still providing developers with the necessary information to debug issues.
- Import the
loggingmodule to enable logging of error details. - Configure the logging settings to log error messages to a file or other logging infrastructure.
- Modify the exception handling block to log the detailed error information and return a generic error message to the user.
-
Copy modified lines R1-R8 -
Copy modified lines R32-R34
| @@ -1,7 +1,9 @@ | ||
| import subprocess | ||
| import uvicorn | ||
| from fastapi import FastAPI | ||
| from dotenv import load_dotenv, set_key | ||
|
|
||
| app = FastAPI() | ||
| import subprocess | ||
| import uvicorn | ||
| from fastapi import FastAPI | ||
| from dotenv import load_dotenv, set_key | ||
| import logging | ||
|
|
||
| logging.basicConfig(filename='app.log', level=logging.ERROR) | ||
| app = FastAPI() | ||
|
|
||
| @@ -29,4 +31,5 @@ | ||
|
|
||
| except subprocess.CalledProcessError as e: | ||
| return {"message": "Script execution failed", "error": str(e), "stderr": e.stderr} | ||
| except subprocess.CalledProcessError as e: | ||
| logging.error(f"Script execution failed: {e}, stderr: {e.stderr}") | ||
| return {"message": "An internal error has occurred. Please try again later."} | ||
|
|
andrewhsugithub
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in input and output folder we can add a .gitignore for privacy
Description
API 範例: http://140.123.97.203:3000/processimg/?param1=input_folder¶m2=output_folder
param1 代表輸入圖片的目錄
param2 代表輸出圖片的目錄
啟動這個 摸server 前需要進入以下 conda 環境: /mnt/Nami/users/Jason0411202/anaconda3/envs/real-esrgan
成功的話應該會長這樣

Changes