Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -16,7 +16,7 @@ Never quite as it seems"""
|
|
16 |
|
17 |
def poem2_generate(word):
|
18 |
p = word.lower() + "\n" + "poem using word: "
|
19 |
-
gr.Markdown("
|
20 |
json_ = {"inputs": p,
|
21 |
"parameters":
|
22 |
{
|
@@ -27,10 +27,10 @@ def poem2_generate(word):
|
|
27 |
}}
|
28 |
response = requests.post(API_URL, headers=headers, json=json_)
|
29 |
output = response.json()
|
30 |
-
gr.Markdown("
|
31 |
output_tmp = output[0]['generated_text']
|
32 |
-
gr.Markdown("
|
33 |
-
|
34 |
if "\n\n" not in output_tmp:
|
35 |
if output_tmp.find('.') != -1:
|
36 |
idx = output_tmp.find('.')
|
@@ -41,14 +41,14 @@ def poem2_generate(word):
|
|
41 |
else:
|
42 |
poem = output_tmp.split("\n\n")[0] # +"."
|
43 |
poem = poem.replace('?','')
|
44 |
-
gr.Markdown("
|
45 |
return poem
|
46 |
|
47 |
|
48 |
def poem_generate(word):
|
49 |
|
50 |
p = prompt + word.lower() + "\n" + "poem using word: "
|
51 |
-
gr.Markdown("
|
52 |
json_ = {"inputs": p,
|
53 |
"parameters":
|
54 |
{
|
@@ -59,9 +59,9 @@ def poem_generate(word):
|
|
59 |
}}
|
60 |
response = requests.post(API_URL, headers=headers, json=json_)
|
61 |
output = response.json()
|
62 |
-
gr.Markdown(
|
63 |
output_tmp = output[0]['generated_text']
|
64 |
-
gr.Markdown("
|
65 |
poem = output[0]['generated_text'].split("\n\n")[0] # +"."
|
66 |
if "\n\n" not in output_tmp:
|
67 |
if output_tmp.find('.') != -1:
|
@@ -73,11 +73,11 @@ def poem_generate(word):
|
|
73 |
else:
|
74 |
poem = output_tmp.split("\n\n")[0] # +"."
|
75 |
poem = poem.replace('?','')
|
76 |
-
gr.Markdown("
|
77 |
return poem
|
78 |
|
79 |
def poem_to_image(poem):
|
80 |
-
gr.Markdown("
|
81 |
poem = " ".join(poem.split('\n'))
|
82 |
poem = poem + " oil on canvas."
|
83 |
steps, width, height, images, diversity = '50','256','256','1',15
|
@@ -91,10 +91,8 @@ def set_example(example: list) -> dict:
|
|
91 |
demo = gr.Blocks()
|
92 |
|
93 |
with demo:
|
94 |
-
gr.Markdown("<h1><center>Few Shot Learning
|
95 |
-
gr.Markdown(
|
96 |
-
"https://huggingface.co/blog/few-shot-learning-gpt-neo-and-inference-api, https://github.com/EleutherAI/the-pile"
|
97 |
-
)
|
98 |
with gr.Row():
|
99 |
input_word = gr.Textbox(lines=7, value=prompt)
|
100 |
|
|
|
16 |
|
17 |
def poem2_generate(word):
|
18 |
p = word.lower() + "\n" + "poem using word: "
|
19 |
+
gr.Markdown("Prompt is :{p}")
|
20 |
json_ = {"inputs": p,
|
21 |
"parameters":
|
22 |
{
|
|
|
27 |
}}
|
28 |
response = requests.post(API_URL, headers=headers, json=json_)
|
29 |
output = response.json()
|
30 |
+
gr.Markdown("error? Reason is : {output}")
|
31 |
output_tmp = output[0]['generated_text']
|
32 |
+
gr.Markdown("GPTJ response without splits is: {output_tmp}")
|
33 |
+
poem = output[0]['generated_text'].split("\n\n")[0] # +"."
|
34 |
if "\n\n" not in output_tmp:
|
35 |
if output_tmp.find('.') != -1:
|
36 |
idx = output_tmp.find('.')
|
|
|
41 |
else:
|
42 |
poem = output_tmp.split("\n\n")[0] # +"."
|
43 |
poem = poem.replace('?','')
|
44 |
+
gr.Markdown("Returned is: {poem}")
|
45 |
return poem
|
46 |
|
47 |
|
48 |
def poem_generate(word):
|
49 |
|
50 |
p = prompt + word.lower() + "\n" + "poem using word: "
|
51 |
+
gr.Markdown("Generate - Prompt is :{p}")
|
52 |
json_ = {"inputs": p,
|
53 |
"parameters":
|
54 |
{
|
|
|
59 |
}}
|
60 |
response = requests.post(API_URL, headers=headers, json=json_)
|
61 |
output = response.json()
|
62 |
+
gr.Markdown(error? Reason is : {output}")
|
63 |
output_tmp = output[0]['generated_text']
|
64 |
+
gr.Markdown("Response without splits is: {output_tmp}")
|
65 |
poem = output[0]['generated_text'].split("\n\n")[0] # +"."
|
66 |
if "\n\n" not in output_tmp:
|
67 |
if output_tmp.find('.') != -1:
|
|
|
73 |
else:
|
74 |
poem = output_tmp.split("\n\n")[0] # +"."
|
75 |
poem = poem.replace('?','')
|
76 |
+
gr.Markdown("Returned is: {poem}")
|
77 |
return poem
|
78 |
|
79 |
def poem_to_image(poem):
|
80 |
+
gr.Markdown("toimage")
|
81 |
poem = " ".join(poem.split('\n'))
|
82 |
poem = poem + " oil on canvas."
|
83 |
steps, width, height, images, diversity = '50','256','256','1',15
|
|
|
91 |
demo = gr.Blocks()
|
92 |
|
93 |
with demo:
|
94 |
+
gr.Markdown("<h1><center>Few Shot Learning Text to Word Image Search</center></h1>")
|
95 |
+
gr.Markdown("https://huggingface.co/blog/few-shot-learning-gpt-neo-and-inference-api, https://github.com/EleutherAI/the-pile")
|
|
|
|
|
96 |
with gr.Row():
|
97 |
input_word = gr.Textbox(lines=7, value=prompt)
|
98 |
|