Amitontheweb commited on
Commit
963d5e6
1 Parent(s): 6155c9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -98
app.py CHANGED
@@ -5,11 +5,11 @@
5
  # - https://huggingface.co/EnglishVoice/t5-base-keywords-to-headline?text=diabetic+diet+plan
6
  # - Apache 2.0
7
 
8
- # In[2]:
9
-
10
 
11
  import torch
12
  from transformers import T5ForConditionalGeneration,T5Tokenizer
 
 
13
 
14
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
15
 
@@ -17,11 +17,6 @@ model = T5ForConditionalGeneration.from_pretrained("EnglishVoice/t5-base-keyword
17
  tokenizer = T5Tokenizer.from_pretrained("EnglishVoice/t5-base-keywords-to-headline", clean_up_tokenization_spaces=True, legacy=False)
18
  model = model.to(device)
19
 
20
-
21
-
22
- # In[5]:
23
-
24
-
25
  def title_gen(keywords):
26
 
27
  text = "headline: " + keywords
@@ -54,14 +49,6 @@ def title_gen(keywords):
54
  return titles
55
 
56
 
57
- # In[1]:
58
-
59
-
60
- import gradio as gr
61
-
62
-
63
- # In[ ]:
64
-
65
 
66
  iface = gr.Interface(fn=paraphrase,
67
  inputs=[gr.Textbox(label="Paste 2 or more keywords searated by a comma.", lines=1), "checkbox", gr.Slider(0.1, 2, 0.8)],
@@ -75,89 +62,6 @@ iface = gr.Interface(fn=paraphrase,
75
  iface.launch()
76
 
77
 
78
- # In[ ]:
79
-
80
-
81
-
82
-
83
-
84
- # In[ ]:
85
-
86
-
87
-
88
-
89
-
90
- # In[ ]:
91
-
92
-
93
-
94
-
95
-
96
- # In[ ]:
97
-
98
-
99
- '''
100
- #Create a four button panel for changing parameters with one click
101
-
102
- def fn(text):
103
- return ("Hello gradio!")
104
-
105
- with gr.Blocks () as demo:
106
-
107
- with gr.Row(variant='compact') as PanelRow1: #first row: top
108
-
109
- with gr.Column(scale=0, min_width=180) as PanelCol5:
110
- gr.HTML("")
111
- with gr.Column(scale=0) as PanelCol4:
112
- submit = gr.Button("Temp++", scale=0)
113
- with gr.Column(scale=1) as PanelCol5:
114
- gr.HTML("")
115
-
116
-
117
- with gr.Row(variant='compact') as PanelRow2: #2nd row: left, right, middle
118
-
119
- with gr.Column(min_width=100) as PanelCol1:
120
- submit = gr.Button("Contrastive")
121
- with gr.Column(min_width=100) as PanelCol2:
122
- submit = gr.Button("Re-generate")
123
- with gr.Column(min_width=100) as PanelCol3:
124
- submit = gr.Button("Diversity Beam")
125
-
126
- with gr.Column(min_width=100) as PanelCol5:
127
- gr.HTML("")
128
- with gr.Column(min_width=100) as PanelCol5:
129
- gr.HTML("")
130
- with gr.Column(scale=0) as PanelCol5:
131
- gr.HTML("")
132
-
133
- with gr.Row(variant='compact') as PanelRow3: #last row: down
134
- with gr.Column(scale=0, min_width=180) as PanelCol7:
135
- gr.HTML("")
136
- with gr.Column(scale=1) as PanelCol6:
137
- submit = gr.Button("Temp--", scale=0)
138
-
139
- with gr.Column(scale=0) as PanelCol5:
140
- gr.HTML("")
141
-
142
- demo.launch()
143
- '''
144
-
145
-
146
- # In[164]:
147
-
148
-
149
- import gc
150
- gc.collect()
151
-
152
-
153
- # In[166]:
154
-
155
-
156
- gr.close_all()
157
-
158
-
159
- # In[ ]:
160
-
161
 
162
 
163
 
 
5
  # - https://huggingface.co/EnglishVoice/t5-base-keywords-to-headline?text=diabetic+diet+plan
6
  # - Apache 2.0
7
 
 
 
8
 
9
  import torch
10
  from transformers import T5ForConditionalGeneration,T5Tokenizer
11
+ import gradio as gr
12
+
13
 
14
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
15
 
 
17
  tokenizer = T5Tokenizer.from_pretrained("EnglishVoice/t5-base-keywords-to-headline", clean_up_tokenization_spaces=True, legacy=False)
18
  model = model.to(device)
19
 
 
 
 
 
 
20
  def title_gen(keywords):
21
 
22
  text = "headline: " + keywords
 
49
  return titles
50
 
51
 
 
 
 
 
 
 
 
 
52
 
53
  iface = gr.Interface(fn=paraphrase,
54
  inputs=[gr.Textbox(label="Paste 2 or more keywords searated by a comma.", lines=1), "checkbox", gr.Slider(0.1, 2, 0.8)],
 
62
  iface.launch()
63
 
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
 
67