mattbitzesty commited on
Commit
51c9105
·
verified ·
1 Parent(s): 194b113

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -199,7 +199,15 @@ def _row_pair(r):
199
 
200
 
201
  def predict(arm_label, rows, progress=gr.Progress()):
202
- pairs = [_row_pair(r) for r in (rows or [])]
 
 
 
 
 
 
 
 
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)."