Spaces:
Sleeping
Sleeping
Redirect issue 1
Browse files- Dockerfile +1 -0
- main.py +4 -1
Dockerfile
CHANGED
|
@@ -7,6 +7,7 @@ ENV PYTHONUNBUFFERED=1
|
|
| 7 |
|
| 8 |
# Set work directory
|
| 9 |
WORKDIR /app
|
|
|
|
| 10 |
|
| 11 |
# Install system dependencies
|
| 12 |
RUN apt-get update && apt-get install -y \
|
|
|
|
| 7 |
|
| 8 |
# Set work directory
|
| 9 |
WORKDIR /app
|
| 10 |
+
ENV MPLCONFIGDIR=/tmp
|
| 11 |
|
| 12 |
# Install system dependencies
|
| 13 |
RUN apt-get update && apt-get install -y \
|
main.py
CHANGED
|
@@ -38,6 +38,8 @@ def root():
|
|
| 38 |
return {"message": "Soil Image Classifier API is running."}
|
| 39 |
|
| 40 |
# Whole image prediction
|
|
|
|
|
|
|
| 41 |
@app.post("/predictsoil/")
|
| 42 |
async def predict_image(file: UploadFile = File(...)):
|
| 43 |
try:
|
|
@@ -58,6 +60,7 @@ async def predict_image(file: UploadFile = File(...)):
|
|
| 58 |
return JSONResponse(status_code=500, content={"error": str(e)})
|
| 59 |
|
| 60 |
# Region-based prediction
|
|
|
|
| 61 |
@app.post("/predict-regions/")
|
| 62 |
async def predict_regions(file: UploadFile = File(...), k_clusters: int = 2):
|
| 63 |
try:
|
|
@@ -93,7 +96,7 @@ async def predict_regions(file: UploadFile = File(...), k_clusters: int = 2):
|
|
| 93 |
except Exception as e:
|
| 94 |
return JSONResponse(status_code=500, content={"error": str(e)})
|
| 95 |
|
| 96 |
-
|
| 97 |
@app.get("/")
|
| 98 |
def home():
|
| 99 |
return {"message": "FastAPI is running on Hugging Face Spaces!"}
|
|
|
|
| 38 |
return {"message": "Soil Image Classifier API is running."}
|
| 39 |
|
| 40 |
# Whole image prediction
|
| 41 |
+
|
| 42 |
+
@app.post("/predictsoil")
|
| 43 |
@app.post("/predictsoil/")
|
| 44 |
async def predict_image(file: UploadFile = File(...)):
|
| 45 |
try:
|
|
|
|
| 60 |
return JSONResponse(status_code=500, content={"error": str(e)})
|
| 61 |
|
| 62 |
# Region-based prediction
|
| 63 |
+
@app.post("/predict-regions")
|
| 64 |
@app.post("/predict-regions/")
|
| 65 |
async def predict_regions(file: UploadFile = File(...), k_clusters: int = 2):
|
| 66 |
try:
|
|
|
|
| 96 |
except Exception as e:
|
| 97 |
return JSONResponse(status_code=500, content={"error": str(e)})
|
| 98 |
|
| 99 |
+
|
| 100 |
@app.get("/")
|
| 101 |
def home():
|
| 102 |
return {"message": "FastAPI is running on Hugging Face Spaces!"}
|