gojiteji commited on
Commit
c2592bc
1 Parent(s): 3fd0786

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -20
app.py CHANGED
@@ -59,31 +59,24 @@ pipeline, params = FlaxStableDiffusionPipeline.from_pretrained(
59
  dtype=jnp.bfloat16,
60
  )
61
 
62
- def text_to_image_and_image_to_text(text,image):
63
- img=None
64
- txt=None
65
- if image "" != None:
 
 
 
 
66
  images = sd2_inference(pipeline, [text], params, seed = 42, num_inference_steps = 5 )
67
  img = images[0]
68
- img = image
69
- if text !=None:
70
- txt=text
71
  return img,txt
72
 
73
- examples = ["apple",
74
- "banana",
75
- "chocolate"]
76
 
77
  if __name__ == '__main__':
78
  interFace = gr.Interface(fn=text_to_image_and_image_to_text,
79
- inputs=[gr.inputs.Textbox(placeholder="Enter the text to Encode to an image", label="Text "
80
- "query",
81
- lines=1),
82
- gr.Image(type="pil")]
83
- outputs=[gr.outputs.Image(type="auto", label="Generated Image"),gr.outputs.Textbox(placeholder="Decoded Text")],
84
- verbose=True,
85
- examples=examples,
86
- title="Generate Image from Text",
87
- description="",
88
- theme="huggingface")
89
  interFace.launch()
 
59
  dtype=jnp.bfloat16,
60
  )
61
 
62
+
63
+
64
+ import gradio as gr
65
+
66
+ def text_to_image_and_image_to_text(text=None,image=None):
67
+ if image != None:
68
+ txt=text
69
+ if text !=None:
70
  images = sd2_inference(pipeline, [text], params, seed = 42, num_inference_steps = 5 )
71
  img = images[0]
 
 
 
72
  return img,txt
73
 
 
 
 
74
 
75
  if __name__ == '__main__':
76
  interFace = gr.Interface(fn=text_to_image_and_image_to_text,
77
+ inputs=[gr.inputs.Textbox(placeholder="Enter the text to Encode to an image", label="Text to Encode to Image ",lines=1,optional=True),gr.Image(type="pil",label="Image to Decode to text",optional=True)],
78
+ outputs=[gr.outputs.Image(type="pil", label="Encoded Image"),gr.outputs.Textbox( label="Decoded Text")],
79
+ title="T2I2T",
80
+ description="T2I2T: Text2Image2Text imformation transmiter"
81
+ )
 
 
 
 
 
82
  interFace.launch()