databoyface commited on
Commit
b507b88
·
verified ·
1 Parent(s): 777530a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -3,9 +3,18 @@ from transformers import pipeline
3
 
4
  pipeline = pipeline(task="text-classification", model="databoyface/distilbert-base-cased-ome-v4.2")
5
 
6
- def predict(input):
7
  predictions = pipeline(input)
8
- return {p["label"]: p["score"] for p in predictions}
 
 
 
 
 
 
 
 
 
9
 
10
  gradio_app = gr.Interface(
11
  fn=predict,
 
3
 
4
  pipeline = pipeline(task="text-classification", model="databoyface/distilbert-base-cased-ome-v4.2")
5
 
6
+ def predict(input: str):
7
  predictions = pipeline(input)
8
+ result = []
9
+ for p in predictions:
10
+ try:
11
+ response = OMEResponse(p["label"])
12
+ except ValueError:
13
+ response = OMEResponse.INDETERMINATE
14
+
15
+ result.append(f"So, {response.reaction} from a result: {response.display_name} with score: {p['score']:.3f} .")
16
+
17
+ return "\n".join(result)
18
 
19
  gradio_app = gr.Interface(
20
  fn=predict,