Maddy21 commited on
Commit
75ee2ec
Β·
1 Parent(s): e3ac0d6
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -14,9 +14,9 @@ app = FastAPI()
14
  # Device configuration
15
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
16
 
17
- # Create model storage directory
18
- MODEL_DIR = "./models"
19
- os.makedirs(MODEL_DIR, exist_ok=True)
20
 
21
  # Model URL from Hugging Face
22
  MODEL_URL = "https://huggingface.co/Maddy21/deepfake-detection-api/resolve/main/best_vit_model.pth"
@@ -80,7 +80,7 @@ def read_root():
80
  # API Endpoint to receive and process video
81
  @app.post("/predict/")
82
  async def predict(file: UploadFile = File(...)):
83
- file_path = f"temp_{file.filename}"
84
 
85
  # Save uploaded video
86
  with open(file_path, "wb") as buffer:
 
14
  # Device configuration
15
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
16
 
17
+ # βœ… Use /tmp/models instead of ./models
18
+ MODEL_DIR = "/tmp/models"
19
+ os.makedirs(MODEL_DIR, exist_ok=True) # βœ… Fix PermissionError
20
 
21
  # Model URL from Hugging Face
22
  MODEL_URL = "https://huggingface.co/Maddy21/deepfake-detection-api/resolve/main/best_vit_model.pth"
 
80
  # API Endpoint to receive and process video
81
  @app.post("/predict/")
82
  async def predict(file: UploadFile = File(...)):
83
+ file_path = f"/tmp/{file.filename}" # βœ… Use /tmp/ instead of current directory
84
 
85
  # Save uploaded video
86
  with open(file_path, "wb") as buffer: