Spaces:
Runtime error
Runtime error
from io import BytesIO | |
import gradio as gr | |
import numpy as np | |
import replicate | |
import requests | |
from PIL import Image | |
def generate(prompt: str): | |
""" | |
γγγ³γγγγηζη»ε(PIL.Image.open)γεεΎ | |
""" | |
output = replicate.run( | |
"stability-ai/sdxl:2b017d9b67edd2ee1401238df49d75da53c523f36e363881e057f5dc3ed3c5b2", | |
input={"prompt": prompt, | |
"seed": np.random.randint(1, 1001)}, | |
) | |
# γͺγ³γ―εεΎ | |
png_link = output[0] | |
# PNGγγ‘γ€γ«γγͺγ³γ―γγεεΎ | |
response = requests.get(png_link) | |
# γ€γ‘γΌγΈγγ‘γ’γͺδΈγ«ιγ | |
img = Image.open(BytesIO(response.content)) | |
return img | |
demo = gr.Interface( | |
generate, | |
inputs=[gr.Textbox(label='γγγ³γγ')], | |
outputs=["image"], | |
examples=["An astronaut riding a rainbow unicorn, cinematic, dramatic"], | |
) | |
if __name__ == "__main__": | |
demo.launch() | |