File size: 767 Bytes
ab0f10a
 
c67a07e
ab0f10a
 
 
b507b88
584b8a3
b507b88
 
 
 
 
 
 
c6f4f17
b507b88
 
ab0f10a
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import gradio as gr
from transformers import pipeline
from OMEresponse import OMEResponse

pipeline = pipeline(task="text-classification", model="databoyface/distilbert-base-cased-ome-v4.2")

def predict(input: str):
    predictions = pipeline(input)
    result = []
    for p in predictions:
        try:
            response = OMEResponse(p["label"])
        except ValueError:
            response = OMEResponse.INDETERMINATE

        result.append(f"So, possibly {response.reaction} from the guess: \"{response.display_name}\" with score: {p['score']:.6f}.")

    return "\n".join(result)
    
gradio_app = gr.Interface(
    fn=predict,
    inputs=["text"],
    outputs=["text"],
    title="How do you feel?",
)

if __name__ == "__main__":
    gradio_app.launch()