SMeyersMrOvkill commited on
Commit
0531416
1 Parent(s): 73fddd5

prompt output

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -95,9 +95,21 @@ def simple_desc(img, prompt):
95
  total = ""
96
  for resp in gen:
97
  print(total := total + resp)
98
- return total
 
 
 
 
 
 
 
 
 
 
 
 
 
99
 
100
- ifc_imgprompt2text = gr.Interface(simple_desc, inputs=[gr.Image(label="input", type="pil"), gr.Textbox(label="prompt")], outputs=[gr.Textbox(label="prompt")])
101
 
102
  """
103
  with gr.Blocks() as demo:
 
95
  total = ""
96
  for resp in gen:
97
  print(total := total + resp)
98
+ img.resize((102,192)).save("tmp.png")
99
+ bts = False
100
+ with open("tmp.png", "rb") as f:
101
+ bts = f.read()
102
+ if bts:
103
+ os.remove("tmp.png")
104
+ res = {
105
+ 'image_b64': base64.b64encode(bts).decode('utf-8'),
106
+ 'description': total,
107
+ }
108
+ return total, res
109
+
110
+ ifc_imgprompt2text = gr.Interface(simple_desc, inputs=[gr.Image(label="input", type="pil"), gr.Textbox(label="prompt")], outputs=[gr.Textbox(label="description"), gr.JSON(label="json")])
111
+
112
 
 
113
 
114
  """
115
  with gr.Blocks() as demo: