JustSkyDev commited on
Commit
39ba66a
·
1 Parent(s): 6be0364

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from PIL import Image
2
+ from fastapi import FastAPI
3
+ from process import Segment
4
+
5
+ app = FastAPI()
6
+
7
+ def process_image(input_image):
8
+ if not isinstance(input_image, Image.Image):
9
+ input_image = Image.fromarray(input_image.astype('uint8'), 'RGB')
10
+
11
+ output_image = Segment(input_image, [0, 0, 0])
12
+ return output_image
13
+
14
+ @app.get("/")
15
+ def root_path():
16
+ return { "log": "Lol" }
17
+
18
+ @app.get("/api/segment/{baseImage}")
19
+ def api_segment(baseImage: str):
20
+ return { "image": process_image(baseImage) }