Kpenciler commited on
Commit
2068945
β€’
1 Parent(s): 9696b5e

add app filr

Browse files
Files changed (2) hide show
  1. app.py +36 -0
  2. 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