Spaces:
Runtime error
Runtime error
add app filr
Browse files- app.py +36 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from io import BytesIO
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
import numpy as np
|
5 |
+
import replicate
|
6 |
+
import requests
|
7 |
+
from PIL import Image
|
8 |
+
|
9 |
+
|
10 |
+
def generate(prompt: str):
|
11 |
+
"""
|
12 |
+
γγγ³γγγγηζη»ε(PIL.Image.open)γεεΎ
|
13 |
+
"""
|
14 |
+
output = replicate.run(
|
15 |
+
"stability-ai/sdxl:2b017d9b67edd2ee1401238df49d75da53c523f36e363881e057f5dc3ed3c5b2",
|
16 |
+
input={"prompt": prompt,
|
17 |
+
"seed": np.random.randint(1, 1001)},
|
18 |
+
)
|
19 |
+
# γͺγ³γ―εεΎ
|
20 |
+
png_link = output[0]
|
21 |
+
# PNGγγ‘γ€γ«γγͺγ³γ―γγεεΎ
|
22 |
+
response = requests.get(png_link)
|
23 |
+
# γ€γ‘γΌγΈγγ‘γ’γͺδΈγ«ιγ
|
24 |
+
img = Image.open(BytesIO(response.content))
|
25 |
+
return img
|
26 |
+
|
27 |
+
|
28 |
+
demo = gr.Interface(
|
29 |
+
generate,
|
30 |
+
inputs=[gr.Textbox(label='γγγ³γγ')],
|
31 |
+
outputs=["image"],
|
32 |
+
examples=["An astronaut riding a rainbow unicorn, cinematic, dramatic"],
|
33 |
+
)
|
34 |
+
|
35 |
+
if __name__ == "__main__":
|
36 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
replicate==0.10.0
|
2 |
+
gradio==3.39.0
|
3 |
+
numpy==1.22.4
|