I’m trying to do a mask of a picture but I’m not obtaining a successful result.
I have to do an inference to the Stable Diffusion Model, but in this way the img2img doesn’t give a good result.
# Convert the image to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Apply thresholding to separate the subjects from the background
_, thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)
# Invert the thresholded image to make the subjects white and the background black
mask = cv2.bitwise_not(thresh)`
New contributor
eliana is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.