Janeka commited on
Commit
22beb92
·
verified ·
1 Parent(s): 62d0a14

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -21
app.py CHANGED
@@ -1,31 +1,14 @@
1
  import gradio as gr
 
2
  from rembg import remove
3
  from PIL import Image
4
- from flask import Flask, Response
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
- # Create Gradio interface using Blocks
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
- app.run(host="0.0.0.0", port=7860)
 
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()