Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120283819
app.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Jul 3, 06:21
Size
655 B
Mime Type
text/x-python
Expires
Sat, Jul 5, 06:21 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
27166574
Attached To
R11149 PDM-Nicola-Oulu
app.py
View Options
from
flask
import
Flask
,
render_template
,
request
from
transformers
import
pipeline
,
set_seed
generator
=
pipeline
(
'text-generation'
,
model
=
'gpt2'
)
# faster to load model outside the loop
app
=
Flask
(
__name__
)
@app.route
(
'/'
)
def
home
():
return
render_template
(
'home.html'
)
@app.route
(
'/authors'
,
methods
=
[
'GET'
,
'POST'
])
def
search_authors
():
search_term
=
request
.
form
[
"input"
]
# gets input from the user defined text.
res
=
generator
(
search_term
,
max_length
=
100
,
num_return_sequences
=
1
)
return
render_template
(
'authors.html'
,
res
=
res
)
if
__name__
==
'__main__'
:
app
.
secret_key
=
'mysecret'
app
.
run
(
port
=
5000
,
debug
=
True
)
Event Timeline
Log In to Comment