segment-anything icon indicating copy to clipboard operation
segment-anything copied to clipboard

Reproducing segmentation results shown in the demo

Open hkzhang-git opened this issue 2 years ago • 4 comments

Here are the segmentation results obtained by using the auto-segmentation button provided on the official website (https://segment-anything.com/demo)

image image

These are the segmentation results generated using the released code. Specifically, I used the ViT-H model with all hyperparameters set to their default values. image image

The results generated by the released code are obviously poorer than those obtained from the official website. Why is this the case, and what model is used in the website version?

hkzhang-git avatar Apr 17 '23 12:04 hkzhang-git

There are likely custom settings applied that may be found in the WebAssembly file located at: https://segment-anything.com/js/ort-wasm-simd.wasm.

Decompiler:

https://webassembly.github.io/wabt/demo/wasm2wat/index.html

Good Luck 😅

Found API?:

{
	"openapi": "3.0.1",
	"info": {
		"title": "RESTful API for: automatic_masks",
		"version": "1.0.0"
	},
	"paths": {
		"/prediction/automatic_masks": {
			"post": {
				"description": "A predict entry point for model: automatic_masks.",
				"operationId": "automatic_masks",
				"parameters": [],
				"responses": {
					"200": {
						"description": "OK"
					},
					"500": {
						"description": "Internal Server Error",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": [
										"code",
										"type",
										"message"],
									"properties": {
										"code": {
											"type": "integer",
											"description": "Error code."
										},
										"type": {
											"type": "string",
											"description": "Error type."
										},
										"message": {
											"type": "string",
											"description": "Error message."
										}
									}
								}
							}
						}
					}
				}
			}
		},
		"/v1/models/{model_name}:predict": {
			"post": {
				"description": "A predict entry point for model: automatic_masks.",
				"operationId": "automatic_masks",
				"parameters": [],
				"responses": {
					"200": {
						"description": "OK"
					},
					"500": {
						"description": "Internal Server Error",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": [
										"code",
										"type",
										"message"],
									"properties": {
										"code": {
											"type": "integer",
											"description": "Error code."
										},
										"type": {
											"type": "string",
											"description": "Error type."
										},
										"message": {
											"type": "string",
											"description": "Error message."
										}
									}
								}
							}
						}
					}
				}
			}
		},
		"/v2/models/{model_name}/infer": {
			"post": {
				"description": "A predict entry point for model: automatic_masks.",
				"operationId": "automatic_masks",
				"parameters": [],
				"responses": {
					"200": {
						"description": "OK"
					},
					"500": {
						"description": "Internal Server Error",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": [
										"code",
										"type",
										"message"],
									"properties": {
										"code": {
											"type": "integer",
											"description": "Error code."
										},
										"type": {
											"type": "string",
											"description": "Error type."
										},
										"message": {
											"type": "string",
											"description": "Error message."
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

ANTONIOPSD avatar Apr 17 '23 12:04 ANTONIOPSD

There are likely custom settings applied that may be found in the WebAssembly file located at: https://segment-anything.com/js/ort-wasm-simd.wasm.

Decompiler:

https://webassembly.github.io/wabt/demo/wasm2wat/index.html

Good Luck 😅

Found API?:

{
	"openapi": "3.0.1",
	"info": {
		"title": "RESTful API for: automatic_masks",
		"version": "1.0.0"
	},
	"paths": {
		"/prediction/automatic_masks": {
			"post": {
				"description": "A predict entry point for model: automatic_masks.",
				"operationId": "automatic_masks",
				"parameters": [],
				"responses": {
					"200": {
						"description": "OK"
					},
					"500": {
						"description": "Internal Server Error",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": [
										"code",
										"type",
										"message"],
									"properties": {
										"code": {
											"type": "integer",
											"description": "Error code."
										},
										"type": {
											"type": "string",
											"description": "Error type."
										},
										"message": {
											"type": "string",
											"description": "Error message."
										}
									}
								}
							}
						}
					}
				}
			}
		},
		"/v1/models/{model_name}:predict": {
			"post": {
				"description": "A predict entry point for model: automatic_masks.",
				"operationId": "automatic_masks",
				"parameters": [],
				"responses": {
					"200": {
						"description": "OK"
					},
					"500": {
						"description": "Internal Server Error",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": [
										"code",
										"type",
										"message"],
									"properties": {
										"code": {
											"type": "integer",
											"description": "Error code."
										},
										"type": {
											"type": "string",
											"description": "Error type."
										},
										"message": {
											"type": "string",
											"description": "Error message."
										}
									}
								}
							}
						}
					}
				}
			}
		},
		"/v2/models/{model_name}/infer": {
			"post": {
				"description": "A predict entry point for model: automatic_masks.",
				"operationId": "automatic_masks",
				"parameters": [],
				"responses": {
					"200": {
						"description": "OK"
					},
					"500": {
						"description": "Internal Server Error",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"required": [
										"code",
										"type",
										"message"],
									"properties": {
										"code": {
											"type": "integer",
											"description": "Error code."
										},
										"type": {
											"type": "string",
											"description": "Error type."
										},
										"message": {
											"type": "string",
											"description": "Error message."
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

Thank you for your response. I followed your suggestion and attempted to locate the custom settings in the WebAssembly file. Unfortunately, I was unable to obtain the information necessary to replicate the segmentation results.

hkzhang-git avatar Apr 18 '23 02:04 hkzhang-git

I'm not sure the issue is within the actual web assembly file, I think the problem is with the backbone model. see the issue i opened here: https://github.com/facebookresearch/segment-anything/issues/224 From what i'm seeing, using the embedding file retrieved from their backbone model gives much better result than the backbone model im hosting locally.

OmerMachluf avatar Apr 20 '23 12:04 OmerMachluf

i am following this issue

shbkukuk avatar May 05 '23 08:05 shbkukuk

I tried using the 2 other as models as well changing some of their parameters and i still get this issue. especially for detecting beards on humans.

mahmoudtabikh avatar May 24 '23 13:05 mahmoudtabikh

I found this problem also. And I used the Hover & Click button to make multiple prompts, but I found the results generated by the released code are obviously poorer than those obtained from the official website demo. I suspect that the model weight of the demo on the official website is different from the weight of the open code, that is to say, the weight of the web demo is not ViT-H.

sssmallmonster avatar Aug 13 '23 03:08 sssmallmonster