Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,31 +1,14 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from rembg import remove
|
| 3 |
from PIL import Image
|
| 4 |
-
|
| 5 |
-
from flask_cors import CORS
|
| 6 |
|
| 7 |
-
# Create a Flask app
|
| 8 |
-
app = Flask(__name__)
|
| 9 |
-
|
| 10 |
-
# Enable CORS for the Flask app
|
| 11 |
-
CORS(app)
|
| 12 |
-
|
| 13 |
-
# Your background removal function
|
| 14 |
def remove_bg(image):
|
| 15 |
output_image = remove(image)
|
| 16 |
return output_image
|
| 17 |
|
| 18 |
-
|
| 19 |
-
with gr.Blocks() as demo:
|
| 20 |
-
gr.Interface(
|
| 21 |
-
fn=remove_bg,
|
| 22 |
-
inputs=gr.Image(type="pil"), # Accept PIL images
|
| 23 |
-
outputs="image", # Output as an image
|
| 24 |
-
)
|
| 25 |
-
|
| 26 |
-
# Mount the Gradio app at the root path
|
| 27 |
-
app = gr.mount_gradio_app(app, demo, path="/")
|
| 28 |
|
| 29 |
-
# Run the Flask app
|
| 30 |
if __name__ == "__main__":
|
| 31 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
from rembg import remove
|
| 4 |
from PIL import Image
|
| 5 |
+
import io
|
|
|
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
def remove_bg(image):
|
| 8 |
output_image = remove(image)
|
| 9 |
return output_image
|
| 10 |
|
| 11 |
+
demo = gr.Interface(fn=remove_bg, inputs=gr.Image(type="pil"), outputs="image")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
|
|
|
| 13 |
if __name__ == "__main__":
|
| 14 |
+
demo.launch()
|