Spaces:
Sleeping
Sleeping
Commit
·
ac5f3b8
1
Parent(s):
00c9e6e
up
Browse files
app.py
CHANGED
|
@@ -12,6 +12,9 @@ import random
|
|
| 12 |
import io
|
| 13 |
import base64
|
| 14 |
import json
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
def removeFurniture(input_img1,
|
| 17 |
input_img2,
|
|
@@ -65,8 +68,11 @@ def segmentation(img):
|
|
| 65 |
return json.dumps(results)
|
| 66 |
|
| 67 |
|
| 68 |
-
def upscale(image):
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
with gr.Blocks() as app:
|
| 72 |
with gr.Row():
|
|
@@ -93,8 +99,9 @@ with gr.Blocks() as app:
|
|
| 93 |
gr.Image()])
|
| 94 |
with gr.Column():
|
| 95 |
gr.Button("Segmentation").click(segmentation, inputs=gr.Image(type="pil"), outputs=gr.JSON())
|
|
|
|
| 96 |
with gr.Column():
|
| 97 |
-
gr.Button("Upscale").click(upscale, inputs=gr.Image(type="pil"), outputs=gr.Image())
|
| 98 |
|
| 99 |
app.launch(debug=True,share=True)
|
| 100 |
|
|
|
|
| 12 |
import io
|
| 13 |
import base64
|
| 14 |
import json
|
| 15 |
+
from diffusers import DiffusionPipeline
|
| 16 |
+
from diffusers import StableDiffusionLatentUpscalePipeline, StableDiffusionPipeline
|
| 17 |
+
|
| 18 |
|
| 19 |
def removeFurniture(input_img1,
|
| 20 |
input_img2,
|
|
|
|
| 68 |
return json.dumps(results)
|
| 69 |
|
| 70 |
|
| 71 |
+
def upscale(image,prompt):
|
| 72 |
+
# pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-x4-upscaler")
|
| 73 |
+
pipeline = StableDiffusionLatentUpscalePipeline.from_pretrained("stabilityai/sd-x2-latent-upscaler", torch_dtype=torch.float32)
|
| 74 |
+
upscaled_image = pipeline(prompt=prompt, image=image).images[0]
|
| 75 |
+
return upscaled_image
|
| 76 |
|
| 77 |
with gr.Blocks() as app:
|
| 78 |
with gr.Row():
|
|
|
|
| 99 |
gr.Image()])
|
| 100 |
with gr.Column():
|
| 101 |
gr.Button("Segmentation").click(segmentation, inputs=gr.Image(type="pil"), outputs=gr.JSON())
|
| 102 |
+
|
| 103 |
with gr.Column():
|
| 104 |
+
gr.Button("Upscale").click(upscale, inputs=[gr.Image(type="pil"),gr.Textbox(label="prompt",value="empty room")], outputs=gr.Image())
|
| 105 |
|
| 106 |
app.launch(debug=True,share=True)
|
| 107 |
|