Spaces:
Runtime error
Runtime error
Upload 4 files
Browse files- app.py +11 -4
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import base64
|
|
| 5 |
import datetime
|
| 6 |
import torch
|
| 7 |
import scipy.io.wavfile
|
| 8 |
-
from fastapi import FastAPI, HTTPException
|
| 9 |
from fastapi.middleware.cors import CORSMiddleware
|
| 10 |
from transformers import AutoProcessor, AutoModelForAudioSeq2Seq
|
| 11 |
from supabase import create_client, Client
|
|
@@ -33,8 +33,15 @@ supabase: Client = create_client(SUPABASE_URL, SUPABASE_KEY)
|
|
| 33 |
# --- Model Loading ---
|
| 34 |
device = "cpu"
|
| 35 |
model_id = "facebook/audiogen-small"
|
| 36 |
-
|
| 37 |
-
model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
is_processing = False
|
| 40 |
|
|
@@ -70,7 +77,7 @@ async def root():
|
|
| 70 |
return {"message": "VidSpri Effects Worker is running", "status": "ok"}
|
| 71 |
|
| 72 |
@app.post("/generate/{job_id}")
|
| 73 |
-
async def generate_effect(job_id: str, prompt: str):
|
| 74 |
await update_status("busy")
|
| 75 |
supabase.table("processing_queue").update({"status": "processing"}).eq("id", job_id).execute()
|
| 76 |
|
|
|
|
| 5 |
import datetime
|
| 6 |
import torch
|
| 7 |
import scipy.io.wavfile
|
| 8 |
+
from fastapi import FastAPI, HTTPException, Form
|
| 9 |
from fastapi.middleware.cors import CORSMiddleware
|
| 10 |
from transformers import AutoProcessor, AutoModelForAudioSeq2Seq
|
| 11 |
from supabase import create_client, Client
|
|
|
|
| 33 |
# --- Model Loading ---
|
| 34 |
device = "cpu"
|
| 35 |
model_id = "facebook/audiogen-small"
|
| 36 |
+
try:
|
| 37 |
+
print(f"Loading model {model_id}...")
|
| 38 |
+
processor = AutoProcessor.from_pretrained(model_id)
|
| 39 |
+
model = AutoModelForAudioSeq2Seq.from_pretrained(model_id).to(device)
|
| 40 |
+
print("Model loaded successfully.")
|
| 41 |
+
except Exception as e:
|
| 42 |
+
print(f"Error loading model: {e}")
|
| 43 |
+
model = None
|
| 44 |
+
processor = None
|
| 45 |
|
| 46 |
is_processing = False
|
| 47 |
|
|
|
|
| 77 |
return {"message": "VidSpri Effects Worker is running", "status": "ok"}
|
| 78 |
|
| 79 |
@app.post("/generate/{job_id}")
|
| 80 |
+
async def generate_effect(job_id: str, prompt: str = Form(...)):
|
| 81 |
await update_status("busy")
|
| 82 |
supabase.table("processing_queue").update({"status": "processing"}).eq("id", job_id).execute()
|
| 83 |
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
fastapi
|
| 2 |
uvicorn
|
| 3 |
python-multipart
|
|
|
|
| 1 |
+
--extra-index-url https://download.pytorch.org/whl/cpu
|
| 2 |
fastapi
|
| 3 |
uvicorn
|
| 4 |
python-multipart
|