Xylor commited on
Commit
cbc4beb
·
verified ·
1 Parent(s): 5e3ae64

Using gradio.JSON()

Browse files

... instead of "json" as return type, and returning list instead of dict. testing if this uses json.dumps instead of repr

Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -23,7 +23,7 @@ def clf_text(txt: str):
23
  # d = dict(zip(res["labels"], res["scores"]))
24
  # output = [f"{lbl}:\t{score}" for lbl, score in items]
25
  # return "\n".join(output)
26
- return dict(items)
27
  # classifier(sequence_to_classify, candidate_labels)
28
  #{'labels': ['travel', 'dancing', 'cooking'],
29
  # 'scores': [0.9938651323318481, 0.0032737774308770895, 0.002861034357920289],
@@ -37,6 +37,6 @@ gradio_interface = gradio.Interface(
37
  # fn = my_inference_function,
38
  fn = clf_text,
39
  inputs = "text",
40
- outputs = "json"
41
  )
42
  gradio_interface.launch()
 
23
  # d = dict(zip(res["labels"], res["scores"]))
24
  # output = [f"{lbl}:\t{score}" for lbl, score in items]
25
  # return "\n".join(output)
26
+ return list(items)
27
  # classifier(sequence_to_classify, candidate_labels)
28
  #{'labels': ['travel', 'dancing', 'cooking'],
29
  # 'scores': [0.9938651323318481, 0.0032737774308770895, 0.002861034357920289],
 
37
  # fn = my_inference_function,
38
  fn = clf_text,
39
  inputs = "text",
40
+ outputs = gradio.JSON()
41
  )
42
  gradio_interface.launch()