File size: 4,195 Bytes
efd35d9
7423182
cf39c35
 
0cbaf27
efd35d9
d3ae8b9
 
8ae1757
 
 
d3ae8b9
246c565
 
 
 
 
 
 
 
 
 
 
 
0cbaf27
 
3195429
997fdd0
 
 
 
 
0cbaf27
 
 
28ed46d
8ae1757
28ed46d
3195429
8ae1757
 
 
 
 
 
 
 
 
3195429
 
 
8ae1757
 
 
3195429
8ae1757
 
3195429
 
8ae1757
 
3195429
 
8ae1757
 
 
 
 
 
 
 
3195429
8ae1757
 
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import gradio as gr
import os
from transformers import pipeline

access_token = os.environ["access_token"]

title = "NX Block Trade: Multilingual Zero Shot News Classification"
description = "powered by xlm-roberta-large-xnli made by @abhisheky127"
# classifier = pipeline("zero-shot-classification",
#                       model="joeddav/xlm-roberta-large-xnli",
#                      token=access_token)

categories = [
    'sports',
     'world',
     'national',
     'politics',
     'automobile',
     'cryptocurrency',
     'education',
     'Coronavirus',
     'business',
     'travel'
             ]


test_examples = [
    ["Redmi 12 5G will be a game-changer for 5G connectivity: XiaomiXiaomi will debut Redmi 12 5G alongside Redmi 12 in India on August 1. Redmi 12 5G, a well-rounded offering in under-15k segment, will begin a new era of connectivity and accessibility, the brand said. Xiaomi was among the first brands to democratize 4G, and with this, it's aiming to repeat history by making 5G accessible to all, it added." , ", ".join(categories), True],
    ["Limited seats left for Hero Vired & MIT’s Program in FinTechHero Group's EdTech company Hero Vired & MIT launched an Integrated Program in Finance and FinTech with placement assistance for working professionals. It's India's only industry-focused online program that integrates MIT Modules & tools like Python, Solidity & Ethereum, the company stated, adding, learners will be eligible for MIT MicroMasters® Program Certificate on clearing respective modules." ,   ",".join(categories), True] ,
    ["Heavy to very heavy rainfall warning issued for several states for Friday, list releasedIMD has issued heavy to very heavy rainfall warning for Madhya Pradesh, Chhattisgarh, Arunachal", ", ".join(categories), True],
    ["Which 14 teams have qualified for 20-team T20 World Cup 2024 so far?Ireland and Scotland have qualified for the 20-team T20 World Cup 2024 from the ongoing Europe Qualifier. Other 12 teams to have already qualified are USA (hosts), West Indies (hosts), Australia, England, India, Netherlands, New Zealand, Pakistan, South Africa, Sri Lanka, Afghanistan and Bangladesh. Remaining six teams will be decided through other qualifying tournaments." , ",".join(categories), True],
    ["अमेरिकी सेना ने बताया है, \"पूर्वोत्तर सीरिया में रविवार को एक हेलीकॉप्टर के दुर्घटनाग्रस्त होने पर 22 अमेरिकी सैनिक घायल हो गए।\" सेना ने कहा, \"घायलों का इलाज चल रहा है। गंभीर रूप से घायल 10 सैनिकों को बेहतर इलाज के लिए क्षेत्र से बाहर ले जाया गया है।\" बकौल सेना, दुर्घटना के कारणों की जांच की जा रही है।", ", ".join(categories), True]
]


gr.load(name="models/joeddav/xlm-roberta-large-xnli", api_key=access_token,
                  title=title, description=description,
                 examples=test_examples).launch(debug=True)

# #define a function to process your input and output
# def zero_shot(doc, candidates):
#     given_labels = candidates.split(",")
#     given_labels = list(map(str.strip, given_labels))
#     print(doc)
#     dictionary = classifier(doc, given_labels)
#     labels = dictionary['labels']
#     scores = dictionary['scores']
#     return dict(zip(labels, scores))



# #create input and output objects
# #input object1
# input1 = gr.Textbox(label="Text")

# #input object 2
# input2 = gr.Textbox(label="Labels")


# #output object
# output = gr.Label(label="Output")


# #create interface
# gui = gr.Interface(title=title,
#                    description=description,
#                    fn=zero_shot,
#                    inputs=[input1, input2],
#                    outputs=[output],
#                    examples=test_examples
#                   )

# #display the interface
# gui.launch(debug=True)