ThereforeGames / txt2mask

Automatically create masks for Stable Diffusion inpainting using natural language.
517 stars 40 forks source link

use better refined model, improve mask generation/padding #15

Open raefu opened 2 years ago

raefu commented 2 years ago

https://github.com/timojl/clipseg#new-fine-grained-weights

Eugenii10 commented 1 year ago

@raefu It seems that code (in the start of process_mask_parts function) replacing re-loading image produces different results. And these results are worse than from original method. It crops parts of the object and make holes in its body.

### ORIGINAL
plt.imsave(filename,torch.sigmoid(these_preds[i][0]))
img = cv2.imread(filename)
gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

### YOUR PATCH
arr = torch.sigmoid(these_preds[i][0]).cpu()
arr = (arr.numpy() * 256).astype(numpy.uint8)

Use frog as a prompt for extension.

ImageOriginal code with refined weightsNew code from patch

Also your commit introduces space indentation in new lines, in some lines it is not constant even (some with 8 spaces, some with 4 spaces). I fixed it in: https://github.com/Eugenii10/txt2mask/tree/fixed-raefu-patch-1