Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
from fastapi import FastAPI, UploadFile, File, HTTPException
|
| 2 |
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
-
from fastapi.responses import StreamingResponse
|
| 4 |
import numpy as np
|
| 5 |
from tensorflow.keras.models import load_model
|
| 6 |
from PIL import Image
|
|
@@ -44,6 +44,11 @@ def preprocess_sketch(image_bytes):
|
|
| 44 |
except Exception as e:
|
| 45 |
raise ValueError(f"Image processing failed: {str(e)}")
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
@app.post("/generate-from-sketch")
|
| 48 |
async def generate_from_sketch(file: UploadFile = File(...)):
|
| 49 |
try:
|
|
@@ -69,3 +74,4 @@ async def generate_from_sketch(file: UploadFile = File(...)):
|
|
| 69 |
except Exception as e:
|
| 70 |
raise HTTPException(status_code=400, detail=str(e))
|
| 71 |
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI, UploadFile, File, HTTPException
|
| 2 |
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
+
from fastapi.responses import StreamingResponse, JSONResponse
|
| 4 |
import numpy as np
|
| 5 |
from tensorflow.keras.models import load_model
|
| 6 |
from PIL import Image
|
|
|
|
| 44 |
except Exception as e:
|
| 45 |
raise ValueError(f"Image processing failed: {str(e)}")
|
| 46 |
|
| 47 |
+
@app.get("/")
|
| 48 |
+
async def health_check():
|
| 49 |
+
"""Health check endpoint"""
|
| 50 |
+
return JSONResponse(content={"status": "API is running", "model": "GAN Image Generator"})
|
| 51 |
+
|
| 52 |
@app.post("/generate-from-sketch")
|
| 53 |
async def generate_from_sketch(file: UploadFile = File(...)):
|
| 54 |
try:
|
|
|
|
| 74 |
except Exception as e:
|
| 75 |
raise HTTPException(status_code=400, detail=str(e))
|
| 76 |
|
| 77 |
+
|