Instructions to use fahimahamed1/NeoNude with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use fahimahamed1/NeoNude with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("fahimahamed1/NeoNude", dtype="auto") - Notebooks
- Google Colab
- Kaggle
File size: 1,283 Bytes
995526c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | """
Phase 2: Mask refinement.
Creates maskref by isolating the green clothing mask from the GAN output
and compositing it onto the corrected image.
"""
import cv2
import numpy as np
def create_maskref(cv_mask, cv_correct):
"""Create the refined mask (maskref) from the raw GAN mask.
Extracts the green clothing region from the GAN mask and overlays it
onto the color-corrected input image.
Args:
cv_mask: Raw mask image from the correct-to-mask GAN phase.
cv_correct: Color-corrected input image.
Returns:
maskref image (512x512 BGR).
"""
# Solid green background
green = np.zeros((512, 512, 3), np.uint8)
green[:, :, :] = (0, 255, 0) # BGR
# Filter for green pixels from the GAN mask
f1 = np.asarray([0, 250, 0])
f2 = np.asarray([10, 255, 10])
green_mask = cv2.inRange(cv_mask, f1, f2)
# Dilate the mask slightly
kernel = np.ones((5, 5), np.uint8)
green_mask = cv2.dilate(green_mask, kernel, iterations=1)
# Composite: keep corrected image outside green, green inside
green_mask_inv = cv2.bitwise_not(green_mask)
res1 = cv2.bitwise_and(cv_correct, cv_correct, mask=green_mask_inv)
res2 = cv2.bitwise_and(green, green, mask=green_mask)
return cv2.add(res1, res2)
|