Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91159375
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
Fri, Nov 8, 12:13
Size
655 B
Mime Type
text/x-python
Expires
Sun, Nov 10, 12:13 (2 d)
Engine
blob
Format
Raw Data
Handle
22208395
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