Spaces:
Sleeping
Sleeping
albin
commited on
Commit
·
3628144
1
Parent(s):
3749a64
modify type answer
Browse files
main.py
CHANGED
|
@@ -39,7 +39,7 @@ def safe_transform(encoder, value):
|
|
| 39 |
if value in encoder.classes_:
|
| 40 |
return encoder.transform([value])[0]
|
| 41 |
else:
|
| 42 |
-
return
|
| 43 |
|
| 44 |
class Msg(BaseModel):
|
| 45 |
msg: str
|
|
@@ -129,7 +129,7 @@ async def predict(request: Request, requess: Req = Depends(form_req)):
|
|
| 129 |
prediction = model.predict(data)
|
| 130 |
output = prediction[0]
|
| 131 |
|
| 132 |
-
output_text =
|
| 133 |
|
| 134 |
# Render index.html with prediction results
|
| 135 |
json_compatible_resp_data = jsonable_encoder(Resp(url=requess.url, label=output_text))
|
|
|
|
| 39 |
if value in encoder.classes_:
|
| 40 |
return encoder.transform([value])[0]
|
| 41 |
else:
|
| 42 |
+
return -1 # Special code for unknown values
|
| 43 |
|
| 44 |
class Msg(BaseModel):
|
| 45 |
msg: str
|
|
|
|
| 129 |
prediction = model.predict(data)
|
| 130 |
output = prediction[0]
|
| 131 |
|
| 132 |
+
output_text = 1 if output == 1 else 0
|
| 133 |
|
| 134 |
# Render index.html with prediction results
|
| 135 |
json_compatible_resp_data = jsonable_encoder(Resp(url=requess.url, label=output_text))
|