Spaces:
Runtime error
Runtime error
import requests | |
import gradio as gr | |
from PIL import Image | |
import base64 | |
def t2i(text): | |
prompt_url = f"https://aadarsh-text-to-image-mymvubi2mq-el.a.run.app/t2i/{text}" | |
img_url = requests.get(prompt_url).json()["url"] | |
response = requests.get(img_url) | |
if response.status_code: | |
fp = open('image.png', 'wb') | |
fp.write(response.content) | |
fp.close() | |
image = Image.open('image.png') | |
return image | |
allow_flagging = "never" | |
title = f""" | |
<h2 style="background-image: linear-gradient(to right, #3A5FCD, #87CEFA); -webkit-background-clip: text; | |
-webkit-text-fill-color: transparent; text-align: center;"> | |
Text to Image Generator | |
</h2> | |
""" | |
description = f""" | |
<div style="display: flex; align-items: center; justify-content: center; flex-direction: column;"> | |
<p style="font-size: 18px; color: #4AAAFF; text-align: center;"> | |
Turn words into captivating visuals effortlessly within minutes. | |
</p> | |
<div style="display: flex; align-items: center; margin-bottom: 0px;"> | |
<img src='data:image/jpeg;base64,{image_base64}' width='50' height='30' style="margin-right: 5px;"/> | |
<p style="font-size: 14px; color: #555;"> | |
Disclaimer: The purpose of this application is solely for demonstration. 1001epochs does not claim ownership for the results Contact: [email protected] for full solution. | |
</p> | |
</div> | |
</div> | |
""" | |
iface = gr.Interface(fn=t2i, inputs="text", outputs=[gr.Image(label="Generated Image")], title=title, description=description).launch() | |
iface.launch(share=True) |