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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -59,21 +59,28 @@ pipeline, params = FlaxStableDiffusionPipeline.from_pretrained(
59
  dtype=jnp.bfloat16,
60
  )
61
 
62
- def text_to_image(text):
63
- images = sd2_inference(pipeline, [text], params, seed = 42, num_inference_steps = 5 )
64
- img = images[0]
65
- return img
 
 
 
 
 
 
66
 
67
  examples = ["apple",
68
  "banana",
69
  "chocolate"]
70
 
71
  if __name__ == '__main__':
72
- interFace = gr.Interface(fn=text_to_image,
73
- inputs=gr.inputs.Textbox(placeholder="Enter the text to Encode to an image", label="Text "
74
  "query",
75
  lines=1),
76
- outputs=gr.outputs.Image(type="auto", label="Generated Image"),
 
77
  verbose=True,
78
  examples=examples,
79
  title="Generate Image from Text",
 
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",