File size: 1,431 Bytes
9c42f3a
b56395a
6f0c225
9c42f3a
 
 
 
 
6f0c225
 
 
 
 
 
 
 
9c42f3a
 
 
 
 
 
 
6f0c225
 
 
 
 
 
 
9c42f3a
 
 
 
 
 
 
 
 
 
 
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# import the main classes
import gradio as gr
import requests


# input examples list
ex_list = [["Women are not as capable as men in leadership roles."],["Women are capable as men in leadership roles."]]


API_URL_Switch = "https://api-inference.huggingface.co/models/google/flan-t5-base"
headers_Switch = {"Authorization": "Bearer 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"}


def query_Switch(payload):
    response = requests.post(API_URL_Switch, headers=headers_Switch, json=payload)
    return response.json()

def classify_gender_equality(input_sentence):
    # Here goes your code to classify gender equality from input_sentence
    # Return the result as a string

    # sub_text = 'Gender equality is important for the progress of society.'
    sub_text = input_sentence
    prompt = f"Please classify the this sentence ( {sub_text} ) as promoting or not promoting gender equality"

    output_temp = query_Switch({
    "inputs": prompt,
    })
   
    return "This sentence is " + output_temp[0]['generated_text'] + " for gender equality"
  



input_text = gr.inputs.Textbox(label="Input Sentence", default="Women deserve equal pay")

# Create the output text field
output_text = gr.outputs.Textbox(label="Gender Equality Classification")

# Create the Gradio interface
gr.Interface(fn=classify_gender_equality, inputs=[input_text], outputs=output_text, title='Gender Equality Classification', examples = ex_list).launch()