dhanushreddy29 commited on
Commit
f0b4848
·
1 Parent(s): c3653b9

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +12 -1
main.py CHANGED
@@ -12,7 +12,7 @@ def remove_background(input_image):
12
  inputs = gr.inputs.Image()
13
  outputs = gr.outputs.Image(type='pil')
14
 
15
- interface = gr.Interface(fn=remove_background, inputs=inputs, outputs=outputs, title="Remove Background", description="This App removes the background from an image.", api="flask", api_description="To use this API, send a POST request to the '/api/remove-background' endpoint with an image file in the 'input' field of the request body.")
16
  interface.launch()
17
 
18
  @app.route("/api/remove-background", methods=["POST"])
@@ -20,3 +20,14 @@ def remove_background_api():
20
  input_image = Image.open(request.files["input"])
21
  output_image = remove_background(input_image)
22
  return jsonify({"output": output_image})
 
 
 
 
 
 
 
 
 
 
 
 
12
  inputs = gr.inputs.Image()
13
  outputs = gr.outputs.Image(type='pil')
14
 
15
+ interface = gr.Interface(fn=remove_background, inputs=inputs, outputs=outputs, title="Remove Background", description="This App removes the background from an image.", api="flask")
16
  interface.launch()
17
 
18
  @app.route("/api/remove-background", methods=["POST"])
 
20
  input_image = Image.open(request.files["input"])
21
  output_image = remove_background(input_image)
22
  return jsonify({"output": output_image})
23
+
24
+ # Custom HTML block with API instructions
25
+ interface.interface_html = """
26
+ <div style="padding: 1rem; margin: 1rem 0; border: 1px solid black;">
27
+ <h3>API Instructions:</h3>
28
+ <ol>
29
+ <li>Send a POST request to the '/api/remove-background' endpoint with an image file in the 'input' field of the request body.</li>
30
+ <li>The output image will be returned as a byte string in the 'output' field of the JSON response.</li>
31
+ </ol>
32
+ </div>
33
+ """