Spaces:
Runtime error
Runtime error
app.py
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
import os
|
|
|
|
|
|
|
|
|
4 |
|
5 |
##Bloom
|
6 |
API_URL = "https://api-inference.huggingface.co/models/bigscience/bloom"
|
@@ -30,11 +34,26 @@ prompt3 = """Q: A juggler can juggle 16 balls. Half of the balls are golf balls,
|
|
30 |
A: Let’s think step by step.
|
31 |
"""
|
32 |
|
|
|
|
|
|
|
|
|
|
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
-
def
|
36 |
|
37 |
-
print(f"*****Inside
|
38 |
#if input_prompt_sql != '':
|
39 |
# prompt = input_prompt_sql #"Instruction: Given an input question, respond with syntactically correct PostgreSQL\nInput: " +input_prompt_sql + "\nPostgreSQL query: "
|
40 |
#elif input_prompt_dalle2 !='':
|
@@ -93,8 +112,9 @@ def text_generate(prompt, generated_txt): #, input_prompt_sql ): #, input_prompt
|
|
93 |
new_prompt = display_output[-first_period_loc:-1]
|
94 |
print(f"Not sending blank as prompt so new prompt for next cycle is : {new_prompt}")
|
95 |
display_output = display_output[:-1]
|
96 |
-
|
97 |
-
|
|
|
98 |
|
99 |
|
100 |
demo = gr.Blocks()
|
@@ -102,7 +122,7 @@ demo = gr.Blocks()
|
|
102 |
with demo:
|
103 |
gr.Markdown("<h1><center>Bloom</center></h1>")
|
104 |
gr.Markdown(
|
105 |
-
"""Testing Bloom
|
106 |
)
|
107 |
with gr.Row():
|
108 |
#example_prompt = gr.Radio( ["Q: A juggler can juggle 16 balls. Half of the balls are golf balls, and half of the golf balls are blue. How many blue golf balls are there?\nA: Let’s think step by step.\n"], label= "Choose a sample Prompt")
|
@@ -117,19 +137,20 @@ with demo:
|
|
117 |
#"Dalle Prompt: Cyberwave vaporpunk art of a kneeling figure, looking up at a glowing neon book icon, smoke and mist, pink and blue lighting, cybernetic sci-fi render\nNew Dalle Prompt: " ], label= "Choose a sample Prompt")
|
118 |
|
119 |
#with gr.Row():
|
120 |
-
|
|
|
121 |
#input_prompt_dalle2 = gr.Textbox(label="Or Write sample Dalle2 prompts to get more Prompt ideas...")
|
122 |
#input_prompt2 = gr.Textbox(label="Write some text to get started...", lines=3, visible=False) #input_prompt_sql
|
123 |
|
124 |
#input_word = gr.Textbox(placeholder="Enter a word here to generate text ...")
|
125 |
-
with gr.Row():
|
126 |
-
generated_txt = gr.Textbox(lines=7, visible = True)
|
127 |
-
|
128 |
|
129 |
-
b1 = gr.Button("Generate
|
130 |
#b2 = gr.Button("Generate Image")
|
131 |
|
132 |
-
b1.click(text_generate, inputs=
|
133 |
#b2.click(poem_to_image, poem_txt, output_image)
|
134 |
#examples=examples
|
135 |
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
import os
|
4 |
+
import PIL
|
5 |
+
from PIL import Image
|
6 |
+
from PIL import ImageDraw
|
7 |
+
from PIL import ImageFont
|
8 |
|
9 |
##Bloom
|
10 |
API_URL = "https://api-inference.huggingface.co/models/bigscience/bloom"
|
|
|
34 |
A: Let’s think step by step.
|
35 |
"""
|
36 |
|
37 |
+
prompt = """Distracted from hubble by james webb.
|
38 |
+
Distracted from homework by side projeect.
|
39 |
+
Distracted from goals by new goals.
|
40 |
+
Distracted from
|
41 |
+
"""
|
42 |
|
43 |
+
def write_on_image(final_solution):
|
44 |
+
print("************ Inside write_on_image ***********")
|
45 |
+
image_path0 = "./distracted0.jpg"
|
46 |
+
image0 = Image.open(image_path0)
|
47 |
+
I1 = ImageDraw.Draw(image0)
|
48 |
+
myfont = ImageFont.truetype('./font1.ttf', 30)
|
49 |
+
I1.text((613, 89), "girlfriend",font=myfont, fill =(255, 255, 255))
|
50 |
+
I1.text((371, 223), "ME", font=myfont, fill =(255, 255, 255))
|
51 |
+
I1.text((142, 336), "new girl",font=myfont, fill =(255, 255, 255))
|
52 |
+
return image0
|
53 |
|
54 |
+
def meme_generate(img): #prompt, generated_txt): #, input_prompt_sql ): #, input_prompt_dalle2):
|
55 |
|
56 |
+
print(f"*****Inside meme_generate - Prompt is :{prompt}")
|
57 |
#if input_prompt_sql != '':
|
58 |
# prompt = input_prompt_sql #"Instruction: Given an input question, respond with syntactically correct PostgreSQL\nInput: " +input_prompt_sql + "\nPostgreSQL query: "
|
59 |
#elif input_prompt_dalle2 !='':
|
|
|
112 |
new_prompt = display_output[-first_period_loc:-1]
|
113 |
print(f"Not sending blank as prompt so new prompt for next cycle is : {new_prompt}")
|
114 |
display_output = display_output[:-1]
|
115 |
+
|
116 |
+
meme_image = write_on_image(final_solution)
|
117 |
+
return meme_image #final_solution #display_output, new_prompt #generated_txt+prompt
|
118 |
|
119 |
|
120 |
demo = gr.Blocks()
|
|
|
122 |
with demo:
|
123 |
gr.Markdown("<h1><center>Bloom</center></h1>")
|
124 |
gr.Markdown(
|
125 |
+
"""Testing Bloom. WIP"""
|
126 |
)
|
127 |
with gr.Row():
|
128 |
#example_prompt = gr.Radio( ["Q: A juggler can juggle 16 balls. Half of the balls are golf balls, and half of the golf balls are blue. How many blue golf balls are there?\nA: Let’s think step by step.\n"], label= "Choose a sample Prompt")
|
|
|
137 |
#"Dalle Prompt: Cyberwave vaporpunk art of a kneeling figure, looking up at a glowing neon book icon, smoke and mist, pink and blue lighting, cybernetic sci-fi render\nNew Dalle Prompt: " ], label= "Choose a sample Prompt")
|
138 |
|
139 |
#with gr.Row():
|
140 |
+
in_image = gr.Image(value="./distracted0.jpg")
|
141 |
+
#input_prompt = gr.Textbox(label="Write some text to get started...", lines=3) #input_prompt_sql
|
142 |
#input_prompt_dalle2 = gr.Textbox(label="Or Write sample Dalle2 prompts to get more Prompt ideas...")
|
143 |
#input_prompt2 = gr.Textbox(label="Write some text to get started...", lines=3, visible=False) #input_prompt_sql
|
144 |
|
145 |
#input_word = gr.Textbox(placeholder="Enter a word here to generate text ...")
|
146 |
+
#with gr.Row():
|
147 |
+
#generated_txt = gr.Textbox(lines=7, visible = True)
|
148 |
+
output_image = gr.Image() #type="filepath", shape=(256,256))
|
149 |
|
150 |
+
b1 = gr.Button("Generate MeMe")
|
151 |
#b2 = gr.Button("Generate Image")
|
152 |
|
153 |
+
b1.click(text_generate, inputs=in_image, outputs=output_image) #input_word #input_prompt_dalle2 #input_prompt_sql #example_prompt
|
154 |
#b2.click(poem_to_image, poem_txt, output_image)
|
155 |
#examples=examples
|
156 |
|