attachment
attachment
attachment
attachment

Make the man stand beside women in orange saree

analyse_media
Browsing Directory

~/

Running Command

mkdir -p "/tmp/workspace/photo-composite/output" && python - <<'PY' from PIL import Image import cv2, numpy as np from pathlib import Path base_path='/tmp/workspace/attachments/5df7e257-fd79-4c03-ab5d-21148c876f42/IMG20261007072059.jpg' man_path='/tmp/workspace/attachments/5df7e257-fd79-4c03-ab5d-21148c876f42/IMG20260930103201.jpg' out='/tmp/workspace/photo-composite/output/man_beside_woman_orange_saree.png' base=cv2.imread(base_path, cv2.IMREAD_COLOR) src=cv2.imread(man_path, cv2.IMREAD_COLOR) # Man crop: include torso, arms, and legs. GrabCut separates him from hospital interior. rect=(685,335,490,1125) mask=np.zeros(src.shape[:2],np.uint8) bgd=np.zeros((1,65),np.float64); fgd=np.zeros((1,65),np.float64) cv2.grabCut(src,mask,rect,bgd,fgd,6,cv2.GC_INIT_WITH_RECT) alpha=np.where((mask==cv2.GC_FGD)|(mask==cv2.GC_PR_FGD),255,0).astype(np.uint8) # Retain only foreground within the crop, eliminate most loose background components. # Crop around meaningful alpha pixels, leaving a small margin. ys,xs=np.where(alpha>0) x0,x1=max(0,xs.min()-8),min(src.shape[1],xs.max()+8) y0,y1=max(0,ys.min()-8),min(src.shape[0],ys.max()+8) fg=src[y0:y1,x0:x1] a=alpha[y0:y1,x0:x1] # Suppress tiny components, keep components associated with the central person. n, labels, stats, cents=cv2.connectedComponentsWithStats((a>0).astype(np.uint8),8) keep=np.zeros_like(a) for i in range(1,n): area=stats[i,cv2.CC_STAT_AREA] cx,cy=cents[i] if area>1000 and 0.10*a.shape[1] < cx < 0.95*a.shape[1]: keep[labels==i]=255 a=keep # Resize man to match room perspective, locate him on the open floor area to woman's right. scale=0.84 neww,newh=round(fg.shape[1]*scale),round(fg.shape[0]*scale) fg=cv2.resize(fg,(neww,newh),interpolation=cv2.INTER_AREA) a=cv2.resize(a,(neww,newh),interpolation=cv2.INTER_AREA) # Feather edge lightly. a=cv2.GaussianBlur(a,(5,5),0) # Place visual feet near the floor of target. Crop may include full figure. x=735; y=350 # Ensure bounds h,w=base.shape[:2] x=max(0,min(x,w-neww)); y=max(0,min(y,h-newh)) roi=base[y:y+newh,x:x+neww].astype(float) A=(a.astype(float)/255.0)[...,None] comp=(fg.astype(float)*A+roi*(1-A)).astype(np.uint8) base[y:y+newh,x:x+neww]=comp cv2.imwrite(out,base,[cv2.IMWRITE_PNG_COMPRESSION,3]) print('source crop', (x0,y0,x1,y1), 'resized', (neww,newh), 'placed', (x,y), 'output',out, 'exists',Path(out).exists()) PY

Reading File
Running Command

python - <<'PY' from PIL import Image im=Image.open('/tmp/workspace/photo-composite/output/man_beside_woman_orange_saree.png') im.thumbnail((900,1200)) im.convert('RGB').save('/tmp/workspace/photo-composite/output/preview.jpg',quality=78,optimize=True) PY

Reading File

man beside woman orange saree

Image · PNG

attachment
attachment
attachment
attachment

Make the man in purple shirt Stand beside women in orange dress and make it look realistic

analyse_media
Browsing Directory

~/

Running Command

python - <<'PY' import importlib.util for x in ['rembg','cv2','torch','transparent_background']: print(x, bool(importlib.util.find_spec(x))) PY

Running Command

mkdir -p "/tmp/workspace/photo-composite-realistic/output" && python - <<'PY' import cv2, numpy as np from pathlib import Path basep='/tmp/workspace/attachments/5df7e257-fd79-4c03-ab5d-21148c876f42/IMG20261007072059 (1).jpg' srcp='/tmp/workspace/attachments/5df7e257-fd79-4c03-ab5d-21148c876f42/IMG20260930103243.jpg' out='/tmp/workspace/photo-composite-realistic/output/man_beside_woman_orange_saree_realistic.jpg' base=cv2.imread(basep); src=cv2.imread(srcp) # Segment the standing man using GrabCut, with a tight rectangle around the person. mask=np.zeros(src.shape[:2],np.uint8); bgd=np.zeros((1,65),np.float64); fgd=np.zeros((1,65),np.float64) cv2.grabCut(src,mask,(680,260,495,1308),bgd,fgd,10,cv2.GC_INIT_WITH_RECT) a=np.where((mask==cv2.GC_FGD)|(mask==cv2.GC_PR_FGD),255,0).astype('uint8') # constrain to a hand-traced broad silhouette, avoiding adjacent bed and room objects. poly=np.array([[780,288],[846,270],[927,294],[985,350],[1067,430],[1175,504],[1175,1380],[1148,1468],[1060,1540],[895,1552],[803,1445],[769,1240],[748,1040],[748,700],[730,525],[745,390]],np.int32) limit=np.zeros_like(a); cv2.fillPoly(limit,[poly],255); a=cv2.bitwise_and(a,limit) # Clean small fragments and preserve only components attached to the main person. n,lab,stats,_=cv2.connectedComponentsWithStats((a>0).astype('uint8'),8) areas=stats[1:,cv2.CC_STAT_AREA]; keepid=1+areas.argmax(); a=np.where(lab==keepid,255,0).astype('uint8') # Hand and forearm touch image right edge and often become a separate part: restore region classified foreground within silhouette. a=np.where((limit>0)&((mask==cv2.GC_FGD)|(mask==cv2.GC_PR_FGD)),255,a).astype('uint8') # crop close to silhouette. ys,xs=np.where(a>0); x0,x1=max(0,xs.min()-8),min(src.shape[1],xs.max()+1); y0,y1=max(0,ys.min()-8),min(src.shape[0],ys.max()+1) fg=src[y0:y1,x0:x1]; a=a[y0:y1,x0:x1] # Rescale to standing height appropriate for target ward perspective. scale=.82; nw,nh=round(fg.shape[1]*scale),round(fg.shape[0]*scale) fg=cv2.resize(fg,(nw,nh),interpolation=cv2.INTER_AREA); a=cv2.resize(a,(nw,nh),interpolation=cv2.INTER_AREA) a=cv2.GaussianBlur(a,(5,5),0) # Position beside woman, against back wall; feet meet the tiled floor. x,y=670,355 # Warm/sharpen coloring is retained from new photo but matched slightly to target's brighter setting. fgf=fg.astype(np.float32); fgf[:,:,0]*=0.97; fgf[:,:,1]*=1.00; fgf[:,:,2]*=1.03 fg=np.clip(fgf,0,255).astype(np.uint8) # Create subtle contact shadow on floor, only below lower body. shadow=np.zeros(base.shape[:2],np.uint8) cv2.ellipse(shadow,(x+int(nw*.58),y+nh-10),(int(nw*.35),16),0,0,360,80,-1) shadow=cv2.GaussianBlur(shadow,(31,31),0) basef=base.astype(np.float32); basef*= (1-(shadow.astype(np.float32)/255*0.18)[...,None]); base=basef.astype(np.uint8) # Layer person. roi=base[y:y+nh,x:x+nw].astype(np.float32); A=(a.astype(np.float32)/255)[...,None] base[y:y+nh,x:x+nw]=(fg.astype(np.float32)*A+roi*(1-A)).astype(np.uint8) # Restore the right-side bed rail as foreground in front of his lower body, matching depth of target photo. original=cv2.imread(basep) # mask rail/frame in polygon where it crosses the person, limited to the obvious foreground bed region. rail=np.zeros(base.shape[:2],np.uint8) cv2.fillPoly(rail,[np.array([[900,600],[1175,605],[1175,1568],[1050,1568],[1035,1290],[1023,1080],[970,950],[930,815]],np.int32)],255) # Use difference-like color/edges? Hard restore only within region makes bed panel and rail natural foreground. base[rail>0]=original[rail>0] cv2.imwrite(out,base,[cv2.IMWRITE_JPEG_QUALITY,94]) print('crop',x0,y0,x1,y1,'placed',nw,nh,'at',x,y, 'exists',Path(out).exists()) PY

Running Command

python - <<'PY' from PIL import Image p='/tmp/workspace/photo-composite-realistic/output/man_beside_woman_orange_saree_realistic.jpg' im=Image.open(p); im.thumbnail((900,1200)); im.save('/tmp/workspace/photo-composite-realistic/output/preview.jpg',quality=80,optimize=True) print(im.size) PY

Reading File

man beside woman orange saree realistic

Image · JPG

This is a shared conversation. Sign in to Orris to start your own chat.