Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -199,7 +199,15 @@ def _row_pair(r):
|
|
| 199 |
|
| 200 |
|
| 201 |
def predict(arm_label, rows, progress=gr.Progress()):
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
pairs = [(l, c) for l, c in pairs if l and c > 0]
|
| 204 |
if not pairs:
|
| 205 |
return None, "Add at least one ingredient (with a concentration > 0)."
|
|
|
|
| 199 |
|
| 200 |
|
| 201 |
def predict(arm_label, rows, progress=gr.Progress()):
|
| 202 |
+
# Gradio 6 delivers a Dataframe input as a pandas DataFrame server-side;
|
| 203 |
+
# normalise to a list of rows first (never use `rows or []` on a DataFrame).
|
| 204 |
+
if rows is None:
|
| 205 |
+
row_list = []
|
| 206 |
+
elif hasattr(rows, "values") and hasattr(rows, "columns"): # pandas DataFrame
|
| 207 |
+
row_list = rows.values.tolist()
|
| 208 |
+
else:
|
| 209 |
+
row_list = list(rows)
|
| 210 |
+
pairs = [_row_pair(r) for r in row_list]
|
| 211 |
pairs = [(l, c) for l, c in pairs if l and c > 0]
|
| 212 |
if not pairs:
|
| 213 |
return None, "Add at least one ingredient (with a concentration > 0)."
|