ihtesham0345 commited on
Commit
3cab236
·
1 Parent(s): ec67f34

InvSR endpoint auto-falls back to MewZoom 4X on CPU

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -191,5 +191,18 @@ async def route_metrics(file: UploadFile = File(...)):
191
 
192
 
193
  @app.post("/upscale/invsr")
194
- async def route_invsr(file: UploadFile = File(...)):
195
- raise HTTPException(400, detail="InvSR (diffusion 4X) needs GPU. This Space is CPU. Use /upscale/2x or /upscale/4x.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
 
192
 
193
  @app.post("/upscale/invsr")
194
+ async def route_invsr(
195
+ file: UploadFile = File(...),
196
+ num_steps: int = Query(1, ge=1, le=5),
197
+ tile_size: int = Query(128, ge=64, le=512),
198
+ ):
199
+ if torch.cuda.is_available():
200
+ raise HTTPException(501, detail="InvSR GPU pipeline not bundled in this Space. Use the Colab notebook.")
201
+ # Fallback to MewZoom 4X on CPU
202
+ logger.info("InvSR endpoint called on CPU — falling back to MewZoom 4X")
203
+ result, info = upscale_image(await file.read(), "4x")
204
+ info["fallback"] = "InvSR not available on CPU, used MewZoom 4X instead"
205
+ return StreamingResponse(
206
+ BytesIO(result), media_type="image/png",
207
+ headers={"X-Info": json.dumps(info)},
208
+ )