Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -59,31 +59,24 @@ pipeline, params = FlaxStableDiffusionPipeline.from_pretrained(
|
|
| 59 |
dtype=jnp.bfloat16,
|
| 60 |
)
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 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()
|