Spaces:
Sleeping
Sleeping
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 |
-
#
|
| 18 |
-
MODEL_DIR = "
|
| 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"
|
| 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:
|