Spaces:
Sleeping
Sleeping
un-index
commited on
Commit
·
a71047c
1
Parent(s):
955083b
app.py
CHANGED
|
@@ -141,11 +141,12 @@ def f(context, temperature, top_p, max_length, model_idx, SPACE_VERIFICATION_KEY
|
|
| 141 |
# try:
|
| 142 |
# NOTE sometimes it seems to contain another array, weird
|
| 143 |
try:
|
|
|
|
| 144 |
# todo fix max_length below, maybe there is a max_new_tokens parameter
|
| 145 |
# try max_length=len(context)+max_length or =len(context)+max_length or make max_length inf or unspecified
|
| 146 |
# note: added max_new_tokens parameter to see whether it actually works, if not remove,
|
| 147 |
# TODO if yes, then make max_length infinite because it seems to be counted as max input length, not output
|
| 148 |
-
generated_text = generator(context,
|
| 149 |
except Exception as e:
|
| 150 |
return "Exception while generating text: " + str(e)
|
| 151 |
# [0][0]['generated_text']
|
|
@@ -181,8 +182,8 @@ iface = gr.Interface(f, [
|
|
| 181 |
gr.inputs.Dropdown(["GPT-J-6B", "GPT-2"], type="index", label="model"),
|
| 182 |
gr.inputs.Textbox(lines=1, placeholder="xxxxxxxx", label="space verification key")
|
| 183 |
|
| 184 |
-
], outputs="text", title=title, examples=examples)
|
| 185 |
-
iface.launch(
|
| 186 |
|
| 187 |
# all below works but testing
|
| 188 |
# import gradio as gr
|
|
|
|
| 141 |
# try:
|
| 142 |
# NOTE sometimes it seems to contain another array, weird
|
| 143 |
try:
|
| 144 |
+
# NOTE after exactly 60 seconds the fn function seems to error: https://discuss.huggingface.co/t/gradio-fn-function-errors-whenever-60-seconds-passed/13048
|
| 145 |
# todo fix max_length below, maybe there is a max_new_tokens parameter
|
| 146 |
# try max_length=len(context)+max_length or =len(context)+max_length or make max_length inf or unspecified
|
| 147 |
# note: added max_new_tokens parameter to see whether it actually works, if not remove,
|
| 148 |
# TODO if yes, then make max_length infinite because it seems to be counted as max input length, not output
|
| 149 |
+
generated_text = generator(context, max_length=400, max_new_tokens=max_length, top_p=top_p, temperature=temperature, num_return_sequences=1)
|
| 150 |
except Exception as e:
|
| 151 |
return "Exception while generating text: " + str(e)
|
| 152 |
# [0][0]['generated_text']
|
|
|
|
| 182 |
gr.inputs.Dropdown(["GPT-J-6B", "GPT-2"], type="index", label="model"),
|
| 183 |
gr.inputs.Textbox(lines=1, placeholder="xxxxxxxx", label="space verification key")
|
| 184 |
|
| 185 |
+
], outputs="text", title=title, examples=examples, enable_queue = True) # deprecated iwthin iface.launch: https://discuss.huggingface.co/t/is-there-a-timeout-max-runtime-for-spaces/12979/3?u=un-index
|
| 186 |
+
iface.launch() # enable_queue=True
|
| 187 |
|
| 188 |
# all below works but testing
|
| 189 |
# import gradio as gr
|