Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -21,6 +21,8 @@ model = keras.models.load_model("./sneaker_category_predictor_v2.keras")
|
|
21 |
# Define expected columns for one-hot encoding
|
22 |
with open("metadata.json", "r") as f:
|
23 |
METADATA_COLUMNS = json.load(f)
|
|
|
|
|
24 |
|
25 |
|
26 |
def encode_metadata(data):
|
@@ -51,8 +53,11 @@ def encode_metadata(data):
|
|
51 |
|
52 |
@app.route("/")
|
53 |
def index():
|
54 |
-
global METADATA_COLUMNS
|
55 |
-
|
|
|
|
|
|
|
56 |
|
57 |
|
58 |
@app.route("/predict", methods=["POST"])
|
|
|
21 |
# Define expected columns for one-hot encoding
|
22 |
with open("metadata.json", "r") as f:
|
23 |
METADATA_COLUMNS = json.load(f)
|
24 |
+
with open("productData.json", "r") as f:
|
25 |
+
products = json.load(f)
|
26 |
|
27 |
|
28 |
def encode_metadata(data):
|
|
|
53 |
|
54 |
@app.route("/")
|
55 |
def index():
|
56 |
+
global METADATA_COLUMNS,products
|
57 |
+
# 6 random products
|
58 |
+
random_products = np.random.choice(products, 6, replace=False).tolist()
|
59 |
+
productsString = json.dumps(random_products,indent=4)
|
60 |
+
return render_template("index.html", metadata=METADATA_COLUMNS,products=random_products,productsString=productsString)
|
61 |
|
62 |
|
63 |
@app.route("/predict", methods=["POST"])
|