Spaces:
Runtime error
Runtime error
Commit
·
cabf426
1
Parent(s):
759a4ed
Update main.py
Browse files
main.py
CHANGED
|
@@ -4,6 +4,7 @@ from dotenv import load_dotenv
|
|
| 4 |
load_dotenv()
|
| 5 |
import prodia
|
| 6 |
import requests
|
|
|
|
| 7 |
import random
|
| 8 |
from datetime import datetime
|
| 9 |
import os
|
|
@@ -46,6 +47,9 @@ def process_input_img2img(init, prompt, negative_prompt, steps, cfg_scale, numbe
|
|
| 46 |
f.write(img_data)
|
| 47 |
return images
|
| 48 |
|
|
|
|
|
|
|
|
|
|
| 49 |
"""
|
| 50 |
def process_input_control(init, prompt, negative_prompt, steps, cfg_scale, number, seed, model, control_model, sampler):
|
| 51 |
images = []
|
|
@@ -205,6 +209,30 @@ with gr.Blocks(theme=theme) as demo:
|
|
| 205 |
outputs=[result_image],
|
| 206 |
)
|
| 207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
with gr.Tab(label="Gallery"):
|
| 209 |
|
| 210 |
gr.load("nateraw/stable_diffusion_gallery", src="spaces")
|
|
|
|
| 4 |
load_dotenv()
|
| 5 |
import prodia
|
| 6 |
import requests
|
| 7 |
+
from rembg import remove
|
| 8 |
import random
|
| 9 |
from datetime import datetime
|
| 10 |
import os
|
|
|
|
| 47 |
f.write(img_data)
|
| 48 |
return images
|
| 49 |
|
| 50 |
+
def segment(image):
|
| 51 |
+
return remove(image)
|
| 52 |
+
|
| 53 |
"""
|
| 54 |
def process_input_control(init, prompt, negative_prompt, steps, cfg_scale, number, seed, model, control_model, sampler):
|
| 55 |
images = []
|
|
|
|
| 209 |
outputs=[result_image],
|
| 210 |
)
|
| 211 |
|
| 212 |
+
with gr.Tab("Remove Background"):
|
| 213 |
+
with gr.Row():
|
| 214 |
+
|
| 215 |
+
with gr.Column():
|
| 216 |
+
i_img = gr.Image(label="Input Image")
|
| 217 |
+
|
| 218 |
+
with gr.Row():
|
| 219 |
+
|
| 220 |
+
with gr.Column():
|
| 221 |
+
run_btn = gr.Button("Remove", variant="primary")
|
| 222 |
+
|
| 223 |
+
with gr.Row():
|
| 224 |
+
|
| 225 |
+
with gr.Column():
|
| 226 |
+
o_img = gr.Image(label="Result Image")
|
| 227 |
+
|
| 228 |
+
run_btn.click(
|
| 229 |
+
segment,
|
| 230 |
+
inputs=[
|
| 231 |
+
i_img,
|
| 232 |
+
],
|
| 233 |
+
outputs=[o_img],
|
| 234 |
+
)
|
| 235 |
+
|
| 236 |
with gr.Tab(label="Gallery"):
|
| 237 |
|
| 238 |
gr.load("nateraw/stable_diffusion_gallery", src="spaces")
|