Amitontheweb commited on
Commit
57defe3
·
verified ·
1 Parent(s): 6acc2ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -68
app.py CHANGED
@@ -1,15 +1,12 @@
1
- #!/usr/bin/env python
2
- # coding: utf-8
3
 
4
  # ### Keywords to Title Generator
5
  # - https://huggingface.co/EnglishVoice/t5-base-keywords-to-headline?text=diabetic+diet+plan
6
  # - Apache 2.0
7
 
8
- # In[7]:
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 +14,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[45]:
23
-
24
-
25
  def title_gen(keywords, diversity, temp):
26
 
27
  if keywords!= "":
@@ -59,14 +51,6 @@ def title_gen(keywords, diversity, temp):
59
  return titles
60
 
61
 
62
- # In[8]:
63
-
64
-
65
- import gradio as gr
66
-
67
-
68
- # In[48]:
69
-
70
 
71
  iface = gr.Interface(fn=title_gen,
72
  inputs=[gr.Textbox(label="Paste one or more keywords searated by a comma and hit 'Submit'.", lines=1), "checkbox", gr.Slider(0.1, 1.9, 1.2)],
@@ -85,54 +69,3 @@ iface = gr.Interface(fn=title_gen,
85
  )
86
 
87
  iface.launch()
88
-
89
-
90
- # In[ ]:
91
-
92
-
93
- '''
94
- #Create a four button panel for changing parameters with one click
95
-
96
- def fn(text):
97
- return ("Hello gradio!")
98
-
99
- with gr.Blocks () as demo:
100
-
101
- with gr.Row(variant='compact') as PanelRow1: #first row: top
102
-
103
- with gr.Column(scale=0, min_width=180) as PanelCol5:
104
- gr.HTML("")
105
- with gr.Column(scale=0) as PanelCol4:
106
- submit = gr.Button("Temp++", scale=0)
107
- with gr.Column(scale=1) as PanelCol5:
108
- gr.HTML("")
109
-
110
-
111
- with gr.Row(variant='compact') as PanelRow2: #2nd row: left, right, middle
112
-
113
- with gr.Column(min_width=100) as PanelCol1:
114
- submit = gr.Button("Contrastive")
115
- with gr.Column(min_width=100) as PanelCol2:
116
- submit = gr.Button("Re-generate")
117
- with gr.Column(min_width=100) as PanelCol3:
118
- submit = gr.Button("Diversity Beam")
119
-
120
- with gr.Column(min_width=100) as PanelCol5:
121
- gr.HTML("")
122
- with gr.Column(min_width=100) as PanelCol5:
123
- gr.HTML("")
124
- with gr.Column(scale=0) as PanelCol5:
125
- gr.HTML("")
126
-
127
- with gr.Row(variant='compact') as PanelRow3: #last row: down
128
- with gr.Column(scale=0, min_width=180) as PanelCol7:
129
- gr.HTML("")
130
- with gr.Column(scale=1) as PanelCol6:
131
- submit = gr.Button("Temp--", scale=0)
132
-
133
- with gr.Column(scale=0) as PanelCol5:
134
- gr.HTML("")
135
-
136
- demo.launch()
137
- '''
138
-
 
 
 
1
 
2
  # ### Keywords to Title Generator
3
  # - https://huggingface.co/EnglishVoice/t5-base-keywords-to-headline?text=diabetic+diet+plan
4
  # - Apache 2.0
5
 
 
 
6
 
7
  import torch
8
  from transformers import T5ForConditionalGeneration,T5Tokenizer
9
+ import gradio as gr
10
 
11
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
12
 
 
14
  tokenizer = T5Tokenizer.from_pretrained("EnglishVoice/t5-base-keywords-to-headline", clean_up_tokenization_spaces=True, legacy=False)
15
  model = model.to(device)
16
 
 
 
 
 
 
17
  def title_gen(keywords, diversity, temp):
18
 
19
  if keywords!= "":
 
51
  return titles
52
 
53
 
 
 
 
 
 
 
 
 
54
 
55
  iface = gr.Interface(fn=title_gen,
56
  inputs=[gr.Textbox(label="Paste one or more keywords searated by a comma and hit 'Submit'.", lines=1), "checkbox", gr.Slider(0.1, 1.9, 1.2)],
 
69
  )
70
 
71
  iface.launch()