app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#@title
|
2 |
+
import numpy as np
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
def inmm(init_image, prompt):
|
6 |
+
(w,h) = init_image.size
|
7 |
+
if w>h :
|
8 |
+
init_image = init_image.crop(((w - h) // 2,0,(w-h)//2 + h,h))
|
9 |
+
init_image = init_image.resize(512,512)
|
10 |
+
|
11 |
+
with autocast("cuda"):
|
12 |
+
image = pipe([prompt], num_inference_steps=50, guidance_scale=7, init_image=init_image)["sample"]
|
13 |
+
return image[0]
|
14 |
+
|
15 |
+
demo = gr.Interface(inmm, inputs=[gr.Image(shape=(512, 512),type="pil"),gr.Textbox(lines=2, placeholder="どんな絵が欲しいか",value ="a heartwarming and calming landscape drawing in <m-mi2i> style")], outputs="image",
|
16 |
+
examples=[["a_img.png", "A heartwarming Canadian wheat field scene in <m-mi2i> style, some houses, silos, and a lake in the distance"],
|
17 |
+
["c_img.png","A heartwarming Landscape on the lake, scenery mirrored on the lake, in <m-mi2i> style"]])
|
18 |
+
demo.launch()
|