Spaces:
Runtime error
Runtime error
File size: 1,564 Bytes
ca7e47e 2068945 ca7e47e 2068945 ca7e47e ac5bb4c bc4e882 ca7e47e 2068945 bde7679 d141707 bde7679 2068945 bde7679 2068945 bde7679 ca7e47e 2068945 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
import os
from io import BytesIO
import gradio as gr
import numpy as np
import replicate
import requests
from PIL import Image
def generate(prompt: str, secret_key: str):
"""
γγγ³γγγγηζη»ε(PIL.Image.open)γεεΎ
"""
if secret_key == os.environ["SECRET_KEY"]:
output = replicate.run(
"stability-ai/sdxl:2b017d9b67edd2ee1401238df49d75da53c523f36e363881e057f5dc3ed3c5b2",
input={"prompt": prompt,
"seed": np.random.randint(1, 1001),
"num_inference_steps": 25},
)
# γͺγ³γ―εεΎ
png_link = output[0]
# PNGγγ‘γ€γ«γγͺγ³γ―γγεεΎ
response = requests.get(png_link)
# γ€γ‘γΌγΈγγ‘γ’γͺδΈγ«ιγ
img = Image.open(BytesIO(response.content))
return img
examples = [
# ["An astronaut riding a rainbow unicorn, cinematic, dramatic", ""],
# ["A robot painted as graffiti on a brick wall. a sidewalk is in front of the wall, and grass is growing out of cracks in the concrete.", ""],
# ["Panda mad scientist mixing sparkling chemicals, artstation.", ""],
["station", ""],
["station, ghibli style", ""],
["Elon Musk", ""],
["Elon Musk playing Shogi", ""],
]
demo = gr.Interface(
generate,
inputs=[gr.Textbox(label='γγγ³γγ'), gr.Textbox(label='γγΉγ―γΌγ')],
outputs=["image"],
examples=examples,
allow_flagging=None,
title="Stable Diffusion XL (SDXL 1.0)"
)
if __name__ == "__main__":
demo.launch()
|