molinari135
commited on
Commit
•
0f16b6f
1
Parent(s):
68f7af7
Update product_return_prediction/api.py
Browse files
product_return_prediction/api.py
CHANGED
@@ -127,8 +127,8 @@ async def root():
|
|
127 |
@app.post("/predict/")
|
128 |
async def predict(products: ProductRequest):
|
129 |
inventory_path: Path = EXTERNAL_DATA_DIR / "inventory.tsv"
|
130 |
-
|
131 |
-
|
132 |
|
133 |
hf_token = os.getenv("inventory_data")
|
134 |
dataset = load_dataset("molinari135/armani-inventory", token=hf_token, data_files="inventory.tsv")
|
@@ -145,14 +145,14 @@ async def predict(products: ProductRequest):
|
|
145 |
filtered_inventory, products.total_customer_purchases, products.total_customer_returns
|
146 |
)
|
147 |
|
148 |
-
models_uri = "https://huggingface.co/molinari135/se4ai-models/resolve/main/"
|
149 |
-
model_path = MODELS_DIR / model_name
|
150 |
-
scaler_path = MODELS_DIR / scaler_name
|
151 |
|
152 |
-
headers = f"Authorization: Bearer {hf_token}"
|
153 |
|
154 |
-
download_file(f"{models_uri}{model_name}", model_path, headers)
|
155 |
-
download_file(f"{models_uri}{scaler_name}", scaler_path, headers)
|
156 |
|
157 |
model = load_model(model_path)
|
158 |
|
|
|
127 |
@app.post("/predict/")
|
128 |
async def predict(products: ProductRequest):
|
129 |
inventory_path: Path = EXTERNAL_DATA_DIR / "inventory.tsv"
|
130 |
+
model_path: Path = MODELS_DIR / "svm.pkl"
|
131 |
+
scaler_file: Path = MODELS_DIR / "scaler.pkl"
|
132 |
|
133 |
hf_token = os.getenv("inventory_data")
|
134 |
dataset = load_dataset("molinari135/armani-inventory", token=hf_token, data_files="inventory.tsv")
|
|
|
145 |
filtered_inventory, products.total_customer_purchases, products.total_customer_returns
|
146 |
)
|
147 |
|
148 |
+
# models_uri = "https://huggingface.co/molinari135/se4ai-models/resolve/main/"
|
149 |
+
# model_path = MODELS_DIR / model_name
|
150 |
+
# scaler_path = MODELS_DIR / scaler_name
|
151 |
|
152 |
+
# headers = f"Authorization: Bearer {hf_token}"
|
153 |
|
154 |
+
# download_file(f"{models_uri}{model_name}", model_path, headers)
|
155 |
+
# download_file(f"{models_uri}{scaler_name}", scaler_path, headers)
|
156 |
|
157 |
model = load_model(model_path)
|
158 |
|