Omnibus commited on
Commit
dc65d72
·
verified ·
1 Parent(s): d77f6e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -23,12 +23,7 @@ def textover(im,text):
23
 
24
  font = ImageFont.truetype("./fonts/unifont-15.0.01.ttf", int(font_size))
25
  draw.text((x, y),text, font = font, fill=t_fill)
26
-
27
-
28
-
29
-
30
-
31
-
32
  def get_concat_h_cut(in1, in2):
33
  im1=Image.open(in1)
34
  im2=Image.open(in2)
@@ -46,7 +41,7 @@ def get_concat_v_cut(im1,theme='light'):
46
  if theme=='light':
47
  color=(255,255,255)
48
  dst = Image.new('RGB', (im1.width, im1.height +200),color=color)
49
- dst.paste(im1, (0, 0))
50
  return dst
51
 
52
 
@@ -101,6 +96,7 @@ def generate(prompt, history):
101
 
102
  def run(inp,model_drop):
103
  prompt=inp['PROMPT']
 
104
  model=loaded_model[int(model_drop)]
105
  out_img=model(prompt)
106
  print(out_img)
@@ -111,6 +107,7 @@ def run(inp,model_drop):
111
  if r.status_code == 200:
112
  out = Image.open(io.BytesIO(r.content))
113
  out=get_concat_v_cut(out)
 
114
  return out
115
 
116
  def run_gpt(in_prompt,history,):
@@ -157,6 +154,5 @@ with gr.Blocks() as app:
157
 
158
  sub_b = submit_b.click(generate, [msg,chatbot],[chatbot,json_out])
159
  sub_im = submit_im.click(run, [json_out,model_drop],[im_out])
160
- sub_e = msg.submit(run, [msg, chatbot,model_drop], [chatbot,im_out])
161
  stop_b.click(None,None,None, cancels=[sub_b,sub_e])
162
  app.launch()
 
23
 
24
  font = ImageFont.truetype("./fonts/unifont-15.0.01.ttf", int(font_size))
25
  draw.text((x, y),text, font = font, fill=t_fill)
26
+ return im
 
 
 
 
 
27
  def get_concat_h_cut(in1, in2):
28
  im1=Image.open(in1)
29
  im2=Image.open(in2)
 
41
  if theme=='light':
42
  color=(255,255,255)
43
  dst = Image.new('RGB', (im1.width, im1.height +200),color=color)
44
+ dst.paste(im1, (0, 200))
45
  return dst
46
 
47
 
 
96
 
97
  def run(inp,model_drop):
98
  prompt=inp['PROMPT']
99
+ text=inp['MEME_TEXT']
100
  model=loaded_model[int(model_drop)]
101
  out_img=model(prompt)
102
  print(out_img)
 
107
  if r.status_code == 200:
108
  out = Image.open(io.BytesIO(r.content))
109
  out=get_concat_v_cut(out)
110
+ out=textover(out,text)
111
  return out
112
 
113
  def run_gpt(in_prompt,history,):
 
154
 
155
  sub_b = submit_b.click(generate, [msg,chatbot],[chatbot,json_out])
156
  sub_im = submit_im.click(run, [json_out,model_drop],[im_out])
 
157
  stop_b.click(None,None,None, cancels=[sub_b,sub_e])
158
  app.launch()