John Graham Reynolds commited on
Commit
01ab558
·
1 Parent(s): 728d57c

update inputs passed to compute and examples

Browse files
Files changed (1) hide show
  1. app.py +8 -12
app.py CHANGED
@@ -19,10 +19,12 @@ local_path = Path(sys.path[0])
19
  test_cases = [ {"predictions":[1,2,3,4,5], "references":[1,2,5,4,3]} ] # configure this randomly using randint generator and feature names?
20
 
21
  # configure this based on the input type, etc. for launch_gradio_widget
22
- def compute(input_df: pd.DataFrame, feature_names: list[str]):
23
 
24
- predicted = [int(num) for num in input_df[feature_names[0]].to_list()]
25
- references = [int(num) for num in input_df[feature_names[1]].to_list()]
 
 
26
 
27
  metric.add_batch(predictions=predicted, references=references)
28
 
@@ -32,15 +34,12 @@ def compute(input_df: pd.DataFrame, feature_names: list[str]):
32
 
33
  space = gr.Interface(
34
  fn=compute,
35
- inputs=[
36
- gr.Dataframe(
37
  headers=feature_names,
38
  col_count=len(feature_names),
39
  row_count=5,
40
  datatype=json_to_string_type(gradio_input_types),
41
  ),
42
- list(feature_names)
43
- ],
44
  outputs=gr.Textbox(label=metric.name),
45
  description=(
46
  metric.info.description + "\nIf this is a text-based metric, make sure to wrap your input in double quotes."
@@ -50,11 +49,8 @@ space = gr.Interface(
50
  article=parse_readme(local_path / "README.md"),
51
  # TODO: load test cases and use them to populate examples
52
  examples=[
53
- [
54
- # consider how to generalize this
55
- parse_test_cases(test_cases, feature_names, gradio_input_types)[0],
56
- feature_names
57
- ]
58
  ],
59
  cache_examples=False
60
  )
 
19
  test_cases = [ {"predictions":[1,2,3,4,5], "references":[1,2,5,4,3]} ] # configure this randomly using randint generator and feature names?
20
 
21
  # configure this based on the input type, etc. for launch_gradio_widget
22
+ def compute(input_df: pd.DataFrame):
23
 
24
+ cols = [col for col in input_df.columns]
25
+
26
+ predicted = [int(num) for num in input_df[cols[0]].to_list()]
27
+ references = [int(num) for num in input_df[cols[1]].to_list()]
28
 
29
  metric.add_batch(predictions=predicted, references=references)
30
 
 
34
 
35
  space = gr.Interface(
36
  fn=compute,
37
+ inputs=gr.Dataframe(
 
38
  headers=feature_names,
39
  col_count=len(feature_names),
40
  row_count=5,
41
  datatype=json_to_string_type(gradio_input_types),
42
  ),
 
 
43
  outputs=gr.Textbox(label=metric.name),
44
  description=(
45
  metric.info.description + "\nIf this is a text-based metric, make sure to wrap your input in double quotes."
 
49
  article=parse_readme(local_path / "README.md"),
50
  # TODO: load test cases and use them to populate examples
51
  examples=[
52
+ # correct depth?
53
+ parse_test_cases(test_cases, feature_names, gradio_input_types)[0]
 
 
 
54
  ],
55
  cache_examples=False
56
  )