File size: 5,031 Bytes
efd35d9
7423182
cf39c35
 
0cbaf27
efd35d9
d3ae8b9
 
8ae1757
 
 
d3ae8b9
0cbaf27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3195429
997fdd0
 
 
 
 
0cbaf27
 
 
8466a7f
8ae1757
c1e9af1
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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',
 'IPL_2023',
 'Article_370',
 'Oscars_2020',
 'sstr',
 'Wimbledon_2023',
 'bank_frauds',
 'nla',
 'startup',
 'world',
 '5f70e894d43821580e6d7044',
 'national',
 'Russia-Ukraine_Conflict',
 '2022_FIFA_World_Cup',
 'GangrapesInManipur',
 'facts',
 'sme',
 'npa',
 '_₹1000_notes_',
 'VIDEO_NEWS',
 'sb',
 'Asian_Games_2022',
 'budget_2018',
 'politics',
 'automobile',
 '₹500',
 'question',
 'rio_olympics',
 'cryptocurrency',
 'education',
 'experiment',
 'assemblyelections2016',
 'science',
 'Ashes_2023',
 'IPL_2021',
 'ngd',
 'no-confidence_motion',
 'Union_Budget_2022-23',
 'technology',
 'BYJUSCrisis',
 'Coronavirus',
 'nwv',
 'sfs',
 'nlb',
 'Health___Fitness',
 'India_Tour_of_West_Indies',
 'kerala_floods',
 'text_image',
 'India_Strikes_Back',
 'delhi_pollution',
 'Women_s_Premier_League_2023',
 'miscellaneous',
 'entertainment',
 'fashion',
 'hatke',
 'business',
 'us_elections',
 'Asia_Cup_2023',
 'travel',
 'कोरोना_वायरस',
 'neg',
 'WTC_FINAL',
 'Union_Budget_2023-24']


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.Interface.load(name="models/joeddav/xlm-roberta-large-xnli", api_key=access_token,
                  title=title, description=description,
                 examples=test_examples).launch()

# #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)