Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -39,8 +39,8 @@ sets_un = np.unique(sets)
|
|
| 39 |
print('unique sets:', sets_un)
|
| 40 |
print(type(sets_un))
|
| 41 |
|
| 42 |
-
|
| 43 |
-
for c in
|
| 44 |
input_names.append(c)
|
| 45 |
if c=="Card":
|
| 46 |
inputs.append(gr.Textbox(value="", label=c))
|
|
@@ -57,6 +57,30 @@ for c in features:
|
|
| 57 |
elif c=="Set Number Eq":
|
| 58 |
inputs.append(gr.Number(label=c, value = 0.0))
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
def predict_record(*args):
|
| 61 |
record = {name: val for name, val in zip(input_names, args)}
|
| 62 |
df_in = pd.DataFrame([record])
|
|
@@ -67,14 +91,10 @@ iface = gr.Interface(
|
|
| 67 |
inputs=inputs,
|
| 68 |
outputs=gr.Textbox(label="Is this card a collector's item?"),
|
| 69 |
title="Pokémon Card Collector's Item Predictor (AutoGluon)",
|
| 70 |
-
description="Predicts whether a Pokémon card is a collector's item."
|
|
|
|
| 71 |
)
|
| 72 |
|
| 73 |
-
examples = [
|
| 74 |
-
["Pikachu V", 2021, "Journey Together", "Full Art", "Mint", 50.0, 0.6],
|
| 75 |
-
["Charizard", 1999, "Base Set", "Holo", "Near Mint", 12.0, 1.4]
|
| 76 |
-
]
|
| 77 |
-
iface.examples = examples
|
| 78 |
|
| 79 |
if __name__ == "__main__":
|
| 80 |
iface.launch()
|
|
|
|
| 39 |
print('unique sets:', sets_un)
|
| 40 |
print(type(sets_un))
|
| 41 |
|
| 42 |
+
desired_order = ["Card", "Year", "Card Set", "Artwork Style", "Condition", "Market Value", "Set Number Eq"]
|
| 43 |
+
for c in desired_order:
|
| 44 |
input_names.append(c)
|
| 45 |
if c=="Card":
|
| 46 |
inputs.append(gr.Textbox(value="", label=c))
|
|
|
|
| 57 |
elif c=="Set Number Eq":
|
| 58 |
inputs.append(gr.Number(label=c, value = 0.0))
|
| 59 |
|
| 60 |
+
examples_dicts = [
|
| 61 |
+
{
|
| 62 |
+
"Card": "Pikachu V",
|
| 63 |
+
"Year": 2021,
|
| 64 |
+
"Card Set": "Journey Together",
|
| 65 |
+
"Artwork Style": "Full Art",
|
| 66 |
+
"Condition": "Mint",
|
| 67 |
+
"Market Value": 50.0,
|
| 68 |
+
"Set Number Eq": 0.6
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"Card": "Charizard",
|
| 72 |
+
"Year": 1999,
|
| 73 |
+
"Card Set": "Base Set",
|
| 74 |
+
"Artwork Style": "Holo",
|
| 75 |
+
"Condition": "Near Mint",
|
| 76 |
+
"Market Value": 12.0,
|
| 77 |
+
"Set Number Eq": 1.4
|
| 78 |
+
}
|
| 79 |
+
]
|
| 80 |
+
|
| 81 |
+
# Convert examples dicts into positional lists matching input_names
|
| 82 |
+
examples = [[ex[name] for name in input_names] for ex in examples_dicts]
|
| 83 |
+
|
| 84 |
def predict_record(*args):
|
| 85 |
record = {name: val for name, val in zip(input_names, args)}
|
| 86 |
df_in = pd.DataFrame([record])
|
|
|
|
| 91 |
inputs=inputs,
|
| 92 |
outputs=gr.Textbox(label="Is this card a collector's item?"),
|
| 93 |
title="Pokémon Card Collector's Item Predictor (AutoGluon)",
|
| 94 |
+
description="Predicts whether a Pokémon card is a collector's item.",
|
| 95 |
+
examples=examples
|
| 96 |
)
|
| 97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
if __name__ == "__main__":
|
| 100 |
iface.launch()
|