Spaces:
Sleeping
Sleeping
cleaning, api desc added
Browse files
main.py
CHANGED
|
@@ -8,16 +8,9 @@ import os
|
|
| 8 |
import json
|
| 9 |
import logging
|
| 10 |
|
| 11 |
-
# logger
|
| 12 |
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)
|
| 13 |
|
| 14 |
-
# logging.debug('This is a debug message')
|
| 15 |
-
# logging.info('This is an info message')
|
| 16 |
-
# logging.warning('This is a warning message')
|
| 17 |
-
# logging.error('This is an error message')
|
| 18 |
-
# logging.critical('This is a critical message')
|
| 19 |
-
|
| 20 |
-
|
| 21 |
# Util Functions & Classes
|
| 22 |
def loading(fp):
|
| 23 |
with open(fp, "rb") as f:
|
|
@@ -102,20 +95,22 @@ class Lands(BaseModel):
|
|
| 102 |
return [i.dict() for i in cls.inputs]
|
| 103 |
|
| 104 |
|
| 105 |
-
# API
|
| 106 |
-
app = FastAPI(title="API"
|
|
|
|
|
|
|
|
|
|
| 107 |
ml_objects = loading(fp=os.path.join("assets", "ml", "crop_recommandation2.pkl"))
|
| 108 |
## Extract the ml components
|
| 109 |
model = ml_objects["model"]
|
| 110 |
scaler = ml_objects["scaler"].set_output(transform="pandas")
|
| 111 |
labels = ml_objects["labels"]
|
| 112 |
-
# = ml_objects[""]
|
| 113 |
|
| 114 |
|
| 115 |
# Endpoints
|
| 116 |
@app.get("/")
|
| 117 |
def root():
|
| 118 |
-
return {"
|
| 119 |
|
| 120 |
|
| 121 |
@app.get("/checkup")
|
|
|
|
| 8 |
import json
|
| 9 |
import logging
|
| 10 |
|
| 11 |
+
# logger
|
| 12 |
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
# Util Functions & Classes
|
| 15 |
def loading(fp):
|
| 16 |
with open(fp, "rb") as f:
|
|
|
|
| 95 |
return [i.dict() for i in cls.inputs]
|
| 96 |
|
| 97 |
|
| 98 |
+
# API Config
|
| 99 |
+
app = FastAPI(title="Agri-Tech API",
|
| 100 |
+
description="This is a ML API for classification of crop to plant on a land regarding some features")
|
| 101 |
+
|
| 102 |
+
# ML Config
|
| 103 |
ml_objects = loading(fp=os.path.join("assets", "ml", "crop_recommandation2.pkl"))
|
| 104 |
## Extract the ml components
|
| 105 |
model = ml_objects["model"]
|
| 106 |
scaler = ml_objects["scaler"].set_output(transform="pandas")
|
| 107 |
labels = ml_objects["labels"]
|
|
|
|
| 108 |
|
| 109 |
|
| 110 |
# Endpoints
|
| 111 |
@app.get("/")
|
| 112 |
def root():
|
| 113 |
+
return {"Description": " This is a ML API for classification of crop to plant on a land regarding some features."}
|
| 114 |
|
| 115 |
|
| 116 |
@app.get("/checkup")
|