sajabdoli commited on
Commit
fcd4753
·
verified ·
1 Parent(s): cb317f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -7
app.py CHANGED
@@ -63,6 +63,19 @@ async def segment_image(file: UploadFile = File(...)):
63
  except Exception as e:
64
  raise HTTPException(status_code=500, detail=str(e))
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  # CVAT-specific endpoint
67
  @app.post("/predict")
68
  async def predict_for_cvat(body: str = Form(...)):
@@ -99,15 +112,17 @@ async def predict_for_cvat(body: str = Form(...)):
99
  # Convert mask to CVAT format
100
  height, width = mask.shape
101
  rle = mask_to_rle(mask)
102
-
103
  return {
 
104
  "annotations": [{
105
- "ObjectID": 1,
106
- "ObjectScore": float(scores[best_mask_idx]),
107
- "RLE": rle,
108
- "PredictionType": "mask",
109
- "width": width,
110
- "height": height
 
 
111
  }]
112
  }
113
  except Exception as e:
 
63
  except Exception as e:
64
  raise HTTPException(status_code=500, detail=str(e))
65
 
66
+
67
+ @app.get("/models")
68
+ def list_models():
69
+ return {
70
+ "models": [
71
+ {
72
+ "name": "sam-cvat",
73
+ "type": "segmentation",
74
+ "labels": ["object"]
75
+ }
76
+ ]
77
+ }
78
+
79
  # CVAT-specific endpoint
80
  @app.post("/predict")
81
  async def predict_for_cvat(body: str = Form(...)):
 
112
  # Convert mask to CVAT format
113
  height, width = mask.shape
114
  rle = mask_to_rle(mask)
 
115
  return {
116
+ "model": "sam-cvat",
117
  "annotations": [{
118
+ "name": "object",
119
+ "score": float(scores[best_mask_idx]),
120
+ "mask": {
121
+ "rle": rle,
122
+ "width": width,
123
+ "height": height
124
+ },
125
+ "type": "mask"
126
  }]
127
  }
128
  except Exception as e: