Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -59,21 +59,28 @@ pipeline, params = FlaxStableDiffusionPipeline.from_pretrained(
|
|
| 59 |
dtype=jnp.bfloat16,
|
| 60 |
)
|
| 61 |
|
| 62 |
-
def
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
examples = ["apple",
|
| 68 |
"banana",
|
| 69 |
"chocolate"]
|
| 70 |
|
| 71 |
if __name__ == '__main__':
|
| 72 |
-
interFace = gr.Interface(fn=
|
| 73 |
-
inputs=gr.inputs.Textbox(placeholder="Enter the text to Encode to an image", label="Text "
|
| 74 |
"query",
|
| 75 |
lines=1),
|
| 76 |
-
|
|
|
|
| 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",
|