Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -84,9 +84,6 @@ transform, ort_session = initialize_model(model_file=model_file)
|
|
| 84 |
class ImageRequest(BaseModel):
|
| 85 |
image: str # base64 encoded image
|
| 86 |
|
| 87 |
-
# Pydantic model for response
|
| 88 |
-
class TextResponse(BaseModel):
|
| 89 |
-
text: str
|
| 90 |
|
| 91 |
@app.post("/predict", response_model=TextResponse)
|
| 92 |
async def predict_captcha(request: ImageRequest):
|
|
@@ -98,10 +95,15 @@ async def predict_captcha(request: ImageRequest):
|
|
| 98 |
# Get prediction
|
| 99 |
text = get_text(img)
|
| 100 |
|
| 101 |
-
return
|
| 102 |
-
|
|
|
|
|
|
|
| 103 |
except Exception as e:
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
@app.get("/health")
|
| 107 |
async def health_check():
|
|
|
|
| 84 |
class ImageRequest(BaseModel):
|
| 85 |
image: str # base64 encoded image
|
| 86 |
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
@app.post("/predict", response_model=TextResponse)
|
| 89 |
async def predict_captcha(request: ImageRequest):
|
|
|
|
| 95 |
# Get prediction
|
| 96 |
text = get_text(img)
|
| 97 |
|
| 98 |
+
return {
|
| 99 |
+
"success": True,
|
| 100 |
+
"text": text
|
| 101 |
+
}
|
| 102 |
except Exception as e:
|
| 103 |
+
return {
|
| 104 |
+
"success": False,
|
| 105 |
+
"error": str(e)
|
| 106 |
+
}
|
| 107 |
|
| 108 |
@app.get("/health")
|
| 109 |
async def health_check():
|