molinari135
commited on
Update product_return_prediction/api.py
Browse files
product_return_prediction/api.py
CHANGED
@@ -2,6 +2,7 @@ from fastapi import FastAPI, HTTPException
|
|
2 |
from pydantic import BaseModel, Field
|
3 |
import pandas as pd
|
4 |
import json
|
|
|
5 |
import pickle
|
6 |
from pathlib import Path
|
7 |
from product_return_prediction.dataset import prepare_inventory, scale_data_with_trained_scaler
|
@@ -114,7 +115,9 @@ async def predict(products: ProductRequest):
|
|
114 |
model_path: Path = MODELS_DIR / "svm.pkl"
|
115 |
scaler_file: Path = MODELS_DIR / "scaler.pkl"
|
116 |
|
117 |
-
|
|
|
|
|
118 |
|
119 |
filtered_inventory = filter_inventory_by_combinations(
|
120 |
inventory, products.models, products.fabrics, products.colours
|
|
|
2 |
from pydantic import BaseModel, Field
|
3 |
import pandas as pd
|
4 |
import json
|
5 |
+
import os
|
6 |
import pickle
|
7 |
from pathlib import Path
|
8 |
from product_return_prediction.dataset import prepare_inventory, scale_data_with_trained_scaler
|
|
|
115 |
model_path: Path = MODELS_DIR / "svm.pkl"
|
116 |
scaler_file: Path = MODELS_DIR / "scaler.pkl"
|
117 |
|
118 |
+
hf_token = os.getenv("inventory_data")
|
119 |
+
inventory_data = load_dataset("molinari135/armani-inventory", token=hf_token, data_files="inventory.tsv")
|
120 |
+
inventory = pd.DataFrame(dataset['train'])
|
121 |
|
122 |
filtered_inventory = filter_inventory_by_combinations(
|
123 |
inventory, products.models, products.fabrics, products.colours
|