Kaushik Bar commited on
Commit
28e4069
1 Parent(s): 75a1819

voc demo 2

Browse files
Files changed (2) hide show
  1. app.py +123 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datetime
2
+ import gradio as gr
3
+ from huggingface_hub import hf_hub_download
4
+ from transformers import pipeline
5
+
6
+ models = {
7
+ 'en': 'Narsil/deberta-large-mnli-zero-cls'
8
+ }
9
+
10
+ hypothesis_templates = {
11
+ 'en': 'This example is {}.'
12
+ }
13
+
14
+ classifiers = {'en': pipeline("zero-shot-classification", hypothesis_template=hypothesis_templates['en'],
15
+ model=models['en'])
16
+ }
17
+
18
+ def prep_examples():
19
+ example_text1 = "The tangy feel in my mouth was a different experience altogether."
20
+ example_labels1 = "Taste;;Smell;;Delivery;;Packaging;;Price"
21
+
22
+ example_text2 = "The aroma was not quite my type."
23
+ example_labels2 = "Taste;;Smell;;Delivery;;Packaging;;Price"
24
+
25
+ example_text3 = "The chocolates came in an attractive orange box."
26
+ example_labels3 = "Taste;;Smell;;Delivery;;Packaging;;Price"
27
+
28
+ example_text4 = "I can barely find this product in any store near where I stay."
29
+ example_labels4 = "This product has availability issues.;;Stores do not stock this product.;;I live in a remote place."
30
+
31
+ example_text5 = "I can barely find the products I love in the stores anywhere in this deserted place where I moved in few days back."
32
+ example_labels5 = "This product has availability issues.;;Stores do not stock this product.;;I live in a remote place."
33
+
34
+ example_text6 = "RATIONALE: The ability of nicotine to suppress body weight is cited as a factor impacting smoking initiation and the failure to quit. Self-administered nicotine in male rats suppresses weight independent of food intake, suggesting that nicotine increases energy expenditure. OBJECTIVE: The current experiment evaluated the impact of self-administered nicotine on metabolism in rats using indirect calorimetry and body composition analysis. METHODS: Adult male rats with ad libitum access to powdered standard rodent chow self-administered intravenous infusions of nicotine (60 μg/kg/infusion or saline control) in daily 1-h sessions in the last hour of the light cycle. Indirect calorimetry measured respiratory exchange ratio (RER), energy expenditure, motor activity, and food and water consumption for 22.5 h between select self-administration sessions. RESULTS: Self-administered nicotine suppressed weight gain and reduced the percent of body fat without altering the percent of lean mass, as measured by Echo MRI. Nicotine reduced RER, indicating increased fat utilization; this effect was observed prior to weight suppression. Moreover, nicotine intake did not affect motor activity or energy expenditure. Daily food intake was not altered by nicotine self-administration; however, a trend in suppression of meal size, a transient suppression of water intake, and an increase in meal frequency was observed. CONCLUSION: These data provide evidence that self-administered nicotine suppresses body weight via increased fat metabolism, independent of significant changes in feeding, activity, or energy expenditure. (Rupprecht et al. 2018)"
35
+ example_labels6 = "Metabolism/metabolites;;Exposure;;Repeated dose toxicity;;Single dose toxicity;;distribution and excretion;;Absorption"
36
+
37
+ example_text7 = "BACKGROUND AND PURPOSE: Tobacco smoke contains many classes of carcinogens and although nicotine is unable to initiate tumourigenesis in humans and rodents, it promotes tumour growth and metastasis in lung tumours by acting on neuronal nicotinic ACh receptors (nAChRs). The aim of this study was to identify molecularly, biochemically and pharmacologically which nAChR subtypes are expressed and functionally activated by nicotine in lung cancer cell lines. EXPERIMENTAL APPROACH: We used A549 and H1975 adenocarcinoma cell lines derived from lung tumours to test the in vitro effects of nicotine, and nAChR subtype-specific peptides and compounds. KEY RESULTS: The two adenocarcinoma cell lines express distinctive nAChR subtypes, and this affects their nicotine-induced proliferation. In A549 cells, nAChRs containing the α7 or α9 subunits not only regulate nicotine-induced cell proliferation but also the activation of the Akt and ERK pathways. Blocking these nAChRs by means of subtype-specific peptides, or silencing their expression by means of subunit-specific siRNAs, abolishes nicotine-induced proliferation and signalling. Moreover, we found that the α7 antagonist MG624 also acts on α9-α10 nAChRs, blocks the effects of nicotine on A549 cells and has dose-dependent cytotoxic activity. CONCLUSIONS AND IMPLICATIONS: These results highlight the pathophysiological role of α7- and α9-containing receptors in promoting non-small cell lung carcinoma cell growth and intracellular signalling and provide a framework for the development of new drugs that specifically target the receptors expressed in lung tumours. (Mucchietto et al. 2018)."
38
+ example_labels7 = "Metabolism/metabolites;;Exposure;;Repeated dose toxicity;;Single dose toxicity;;Carcinogenicity;;Cytotoxicity;;distribution and excretion;;Absorption"
39
+
40
+ example_text8 = "It is well-documented that nicotine, the main active ingredient in cigarettes, results in endothelial cell injury in numerous diseases. However, whether nicotine plays a crucial role in endothelial cell injury in diabetes and the exact molecular mechanism that mediates this process have not been fully elucidated. The current study aimed to investigate the effects of nicotine on endothelial cell injury in diabetes and the specific molecular mechanism by which it plays a role. Human umbilical vein endothelial cells (HUVECs) were incubated in HG/HF media and treated with nicotine, PYR-41 (a selective ubiquitin E1 inhibitor), Akt-overexpressing adenovirus, or TTC3 and MUL1 shRNA adenovirus. Cell viability was subsequently detected by the CCK8 assay, and apoptosis was examined by caspase-3 cleavage and activity analysis. Compared to the HG/HF incubated group, nicotine incubation significantly decreased cell survival and increased apoptosis. Moreover, nicotine induced Akt degradation via UPS, and Akt overexpression blocked nicotine-induced apoptosis in HUVECs cultured in HG/HF media. Furthermore, the TTC3 and MUL1 shRNA adenovirus dramatically decreased the Akt ubiquitination and apoptosis induced by nicotine. These results indicate that nicotine-induced Akt ubiquitination and degradation occurs through TTC3 and MUL1 and results in a dramatic increase in apoptosis in HUVECs cultured in HG/HF media. (Cao et al. 2018)."
41
+ example_labels8 = "Metabolism/metabolites;;Exposure;;Repeated dose toxicity;;Single dose toxicity;;Carcinogenicity;;Cytotoxicity;;distribution and excretion;;Absorption"
42
+
43
+ example_text9 = "Elephants are"
44
+ example_labels9 = "big;;small;;strong;;fast;;carnivorous"
45
+
46
+ example_text10 = "Do dogs really make better pets than cats or hamsters?"
47
+ example_labels10 = "kittens;;hamsters;;cats;;dogs"
48
+
49
+ example_text11 = "He is hungry."
50
+ example_labels11 = "Positive;;Negative"
51
+
52
+ example_text12 = "He is hungry to learn."
53
+ example_labels12 = "Positive;;Negative"
54
+
55
+ example_text13 = "Gogh was playing with his brush."
56
+ example_labels13 = "Painting;;Amusement;;Sport"
57
+
58
+ example_text14 = "He was playing with his brush."
59
+ example_labels14 = "Painting;;Amusement;;Sport"
60
+
61
+ example_text15 = "Googh was sitting by the window. He was playing with his brush."
62
+ example_labels15 = "Painting;;Amusement;;Sport"
63
+
64
+ example_text16 = "Microsoft has turned itself around."
65
+ example_labels16 = "Under the leadership of Nadella;;Despite the leadership of Nadella;;And Nadella had nothing to do with it;;Under the leadership of Pichai"
66
+
67
+ examples = [
68
+ [example_text1, example_labels1, False],
69
+ [example_text2, example_labels2, False],
70
+ [example_text3, example_labels3, False],
71
+ [example_text4, example_labels4, False],
72
+ [example_text5, example_labels5, False],
73
+ [example_text6, example_labels6, False],
74
+ [example_text7, example_labels7, False],
75
+ [example_text8, example_labels8, False],
76
+ [example_text9, example_labels9, True],
77
+ [example_text10, example_labels10, False],
78
+ [example_text11, example_labels11, False],
79
+ [example_text12, example_labels12, False],
80
+ [example_text13, example_labels13, False],
81
+ [example_text14, example_labels14, False],
82
+ [example_text15, example_labels15, False],
83
+ [example_text16, example_labels16, False]]
84
+
85
+ return examples
86
+
87
+ def sequence_to_classify(sequence, labels, multi_label):
88
+ lang = 'en'
89
+ classifier = classifiers[lang]
90
+
91
+ label_clean = str(labels).split(";;")
92
+ response = classifier(sequence, label_clean, multi_label=multi_label)
93
+
94
+ predicted_labels = response['labels']
95
+ predicted_scores = response['scores']
96
+ clean_output = {idx: float(predicted_scores.pop(0)) for idx in predicted_labels}
97
+ print("Date:{}, Sequence:{}, Labels: {}".format(
98
+ str(datetime.datetime.now()),
99
+ sequence,
100
+ predicted_labels))
101
+
102
+ if not multi_label:
103
+ top_label_key = list(clean_output.keys())[0]
104
+ clean_output = {top_label_key: clean_output[top_label_key]}
105
+ return clean_output
106
+
107
+ iface = gr.Interface(
108
+ title="ZSC Demo 2",
109
+ description="Off-the-shelf NLP classifier with no domain or task-specific training.",
110
+ fn=sequence_to_classify,
111
+ inputs=[gr.inputs.Textbox(lines=10,
112
+ label="Please enter the text you would like to classify...",
113
+ placeholder="Text here..."),
114
+ gr.inputs.Textbox(lines=2,
115
+ label="Please enter the candidate labels (separated by 2 consecutive semicolons)...",
116
+ placeholder="Labels here separated by ;;"),
117
+ gr.inputs.Radio(choices=[False, True],
118
+ label="Multi-label?")],
119
+ outputs=gr.outputs.Label(),
120
+ examples=prep_examples())
121
+
122
+ iface.launch()
123
+
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ transformers
2
+ torch