Spaces:
Sleeping
Sleeping
un-index
commited on
Commit
·
f5f0157
1
Parent(s):
02037ab
app.py
CHANGED
|
@@ -100,7 +100,7 @@ def f(context, temperature, top_p, max_length, model_idx, SPACE_VERIFICATION_KEY
|
|
| 100 |
|
| 101 |
# maybe try "0" instead or 1, or "1"
|
| 102 |
# use GPT-J-6B
|
| 103 |
-
if model_idx ==
|
| 104 |
if main_gpt_j_api_up:
|
| 105 |
# for this api, a length of > 250 instantly errors, so use a while loop or something
|
| 106 |
# that would fetch results in chunks of 250
|
|
@@ -154,7 +154,7 @@ def f(context, temperature, top_p, max_length, model_idx, SPACE_VERIFICATION_KEY
|
|
| 154 |
response = requests.post(
|
| 155 |
"http://api.vicgalle.net:5000/generate", params=payload).json()
|
| 156 |
return response['text']
|
| 157 |
-
elif model_idx ==
|
| 158 |
# use GPT-2
|
| 159 |
#
|
| 160 |
try:
|
|
@@ -210,7 +210,7 @@ def f(context, temperature, top_p, max_length, model_idx, SPACE_VERIFICATION_KEY
|
|
| 210 |
# data = json.dumps(payload)
|
| 211 |
# response = requests.request("POST", API_URL, data=data, headers=headers)
|
| 212 |
# generated_text = json.loads(response.content.decode("utf-8"))[0]['generated_text']
|
| 213 |
-
return generated_text#context #_context+generated_text
|
| 214 |
elif model_idx == 3:
|
| 215 |
url = "https://api-inference.huggingface.co/models/gpt2-large"
|
| 216 |
|
|
@@ -246,7 +246,7 @@ iface = gr.Interface(f, [
|
|
| 246 |
top_p,
|
| 247 |
gr.inputs.Slider(
|
| 248 |
minimum=20, maximum=512, default=30, label="max length"),
|
| 249 |
-
gr.inputs.Dropdown(["GPT-J-6B", "
|
| 250 |
gr.inputs.Textbox(lines=1, placeholder="xxxxxxxx", label="space verification key")
|
| 251 |
|
| 252 |
], 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
|
|
|
|
| 100 |
|
| 101 |
# maybe try "0" instead or 1, or "1"
|
| 102 |
# use GPT-J-6B
|
| 103 |
+
if model_idx == 1:
|
| 104 |
if main_gpt_j_api_up:
|
| 105 |
# for this api, a length of > 250 instantly errors, so use a while loop or something
|
| 106 |
# that would fetch results in chunks of 250
|
|
|
|
| 154 |
response = requests.post(
|
| 155 |
"http://api.vicgalle.net:5000/generate", params=payload).json()
|
| 156 |
return response['text']
|
| 157 |
+
elif model_idx == 0:
|
| 158 |
# use GPT-2
|
| 159 |
#
|
| 160 |
try:
|
|
|
|
| 210 |
# data = json.dumps(payload)
|
| 211 |
# response = requests.request("POST", API_URL, data=data, headers=headers)
|
| 212 |
# generated_text = json.loads(response.content.decode("utf-8"))[0]['generated_text']
|
| 213 |
+
# return generated_text#context #_context+generated_text
|
| 214 |
elif model_idx == 3:
|
| 215 |
url = "https://api-inference.huggingface.co/models/gpt2-large"
|
| 216 |
|
|
|
|
| 246 |
top_p,
|
| 247 |
gr.inputs.Slider(
|
| 248 |
minimum=20, maximum=512, default=30, label="max length"),
|
| 249 |
+
gr.inputs.Dropdown([ "GPT2","GPT-J-6B", "DistilGPT2", "GPT-Large", "GPT-Neo-2.7B"], type="index", label="model"),
|
| 250 |
gr.inputs.Textbox(lines=1, placeholder="xxxxxxxx", label="space verification key")
|
| 251 |
|
| 252 |
], 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
|