ishworrsubedii commited on
Commit
e383c7d
Β·
1 Parent(s): 4ea7bfb

fix: import facemeshdetector and remove logger

Browse files
app.py CHANGED
@@ -11,9 +11,10 @@ import gc
11
  import math
12
  import cvzone
13
  from cvzone.PoseModule import PoseDetector
 
14
  import spaces
15
 
16
- choker_images = [Image.open(os.path.join("choker", x)) for x in os.listdir("choker")]
17
  person_images = [Image.open(os.path.join("without_necklace", x)) for x in os.listdir("without_necklace")]
18
 
19
  model_id = "stabilityai/stable-diffusion-2-inpainting"
@@ -38,8 +39,6 @@ def clothing_try_on_n_necklace_try_on(image, jewellery):
38
  copy_image = image.copy()
39
  jewellery = np.array(jewellery)
40
 
41
- logger.info(f"NECKLACE TRY ON :: detecting pose and landmarks :: {storename}")
42
-
43
  image = detector.findPose(image)
44
  lmList, _ = detector.findPosition(image, bboxWithHands=False, draw=False)
45
 
@@ -51,7 +50,6 @@ def clothing_try_on_n_necklace_try_on(image, jewellery):
51
  landmarksDistance = int(
52
  ((leftLandmark[0] - rightLandmark[0]) ** 2 + (leftLandmark[1] - rightLandmark[1]) ** 2) ** 0.5)
53
 
54
- logger.info(f"NECKLACE TRY ON :: estimating neck points")
55
 
56
  avg_x1 = int(leftLandmark[0] - landmarksDistance * 0.12)
57
  avg_x2 = int(rightLandmark[0] + landmarksDistance * 0.12)
@@ -59,7 +57,6 @@ def clothing_try_on_n_necklace_try_on(image, jewellery):
59
  avg_y1 = int(leftLandmark[1] + landmarksDistance * 0.5)
60
  avg_y2 = int(rightLandmark[1] + landmarksDistance * 0.5)
61
 
62
- logger.info(f"NECKLACE TRY ON :: scaling the necklace image ")
63
 
64
  if avg_y2 < avg_y1:
65
  angle = math.ceil(
@@ -79,7 +76,6 @@ def clothing_try_on_n_necklace_try_on(image, jewellery):
79
  origImgRatio = xdist / jewellery.shape[1]
80
  ydist = jewellery.shape[0] * origImgRatio
81
 
82
- logger.info(f"NECKLACE TRY ON :: adding offset based on the necklace shape")
83
 
84
  image_gray = cv2.cvtColor(jewellery, cv2.COLOR_BGRA2GRAY)
85
  for offset_orig in range(image_gray.shape[1]):
@@ -94,9 +90,6 @@ def clothing_try_on_n_necklace_try_on(image, jewellery):
94
  )
95
  jewellery = cvzone.rotateImage(jewellery, angle)
96
  y_coordinate = avg_y1 - offset
97
-
98
- logger.info(f"NECKLACE TRY ON :: generating output :: {storename}")
99
-
100
  result = cvzone.overlayPNG(copy_image, jewellery, (avg_x1, y_coordinate))
101
 
102
  blackedNecklace = np.zeros(shape=copy_image.shape)
@@ -176,4 +169,3 @@ with gr.Blocks() as interface:
176
  submit.click(fn=clothing_try_on_n_necklace_try_on, inputs=[inputImage, selectedNecklace], outputs=[outputOne])
177
 
178
  interface.launch(debug=True)
179
-
 
11
  import math
12
  import cvzone
13
  from cvzone.PoseModule import PoseDetector
14
+ from cvzone.FaceMeshModule import FaceMeshDetector
15
  import spaces
16
 
17
+ choker_images = [Image.open(os.path.join("short_necklace", x)) for x in os.listdir("short_necklace")]
18
  person_images = [Image.open(os.path.join("without_necklace", x)) for x in os.listdir("without_necklace")]
19
 
20
  model_id = "stabilityai/stable-diffusion-2-inpainting"
 
39
  copy_image = image.copy()
40
  jewellery = np.array(jewellery)
41
 
 
 
42
  image = detector.findPose(image)
43
  lmList, _ = detector.findPosition(image, bboxWithHands=False, draw=False)
44
 
 
50
  landmarksDistance = int(
51
  ((leftLandmark[0] - rightLandmark[0]) ** 2 + (leftLandmark[1] - rightLandmark[1]) ** 2) ** 0.5)
52
 
 
53
 
54
  avg_x1 = int(leftLandmark[0] - landmarksDistance * 0.12)
55
  avg_x2 = int(rightLandmark[0] + landmarksDistance * 0.12)
 
57
  avg_y1 = int(leftLandmark[1] + landmarksDistance * 0.5)
58
  avg_y2 = int(rightLandmark[1] + landmarksDistance * 0.5)
59
 
 
60
 
61
  if avg_y2 < avg_y1:
62
  angle = math.ceil(
 
76
  origImgRatio = xdist / jewellery.shape[1]
77
  ydist = jewellery.shape[0] * origImgRatio
78
 
 
79
 
80
  image_gray = cv2.cvtColor(jewellery, cv2.COLOR_BGRA2GRAY)
81
  for offset_orig in range(image_gray.shape[1]):
 
90
  )
91
  jewellery = cvzone.rotateImage(jewellery, angle)
92
  y_coordinate = avg_y1 - offset
 
 
 
93
  result = cvzone.overlayPNG(copy_image, jewellery, (avg_x1, y_coordinate))
94
 
95
  blackedNecklace = np.zeros(shape=copy_image.shape)
 
169
  submit.click(fn=clothing_try_on_n_necklace_try_on, inputs=[inputImage, selectedNecklace], outputs=[outputOne])
170
 
171
  interface.launch(debug=True)
 
choker/necklace_1.png DELETED

Git LFS Details

  • SHA256: e7497a74a75ab48888d49de4a4f334f7156f6079ff461aaee0b748fa2ae35cce
  • Pointer size: 132 Bytes
  • Size of remote file: 1.45 MB
choker/necklace_11.png DELETED

Git LFS Details

  • SHA256: b437f1708c7ee396039f0e72fd7c9330d015003b96802130890a043ccbee60ad
  • Pointer size: 132 Bytes
  • Size of remote file: 1.41 MB
choker/necklace_12.png DELETED

Git LFS Details

  • SHA256: ac2c64c8c4596a556c9a63e8a7ea2a77afc5f626b37aa288815fb3f555d13d96
  • Pointer size: 132 Bytes
  • Size of remote file: 1.44 MB
choker/necklace_20.png DELETED

Git LFS Details

  • SHA256: d969b23634c25621253806fa2a51e956523f9ce35b4044a98aff608c9be568fd
  • Pointer size: 132 Bytes
  • Size of remote file: 1.48 MB
choker/necklace_27.png DELETED

Git LFS Details

  • SHA256: e227d0d5b01b97cfb51c53f56d521924bb3b3ec3cc5e3e363f59ea0b1318dfdd
  • Pointer size: 132 Bytes
  • Size of remote file: 1.61 MB
choker/necklace_29.png DELETED

Git LFS Details

  • SHA256: b76950c96d027b5a4a7c1b2e5d198b1abadc48a8d0a040850b6376cc745c408a
  • Pointer size: 132 Bytes
  • Size of remote file: 1.52 MB
choker/necklace_48.png DELETED

Git LFS Details

  • SHA256: 53ede0432e4e9d472c86b974ebb489055a6243ad8a8751a4bcf732cc9badd470
  • Pointer size: 132 Bytes
  • Size of remote file: 1.33 MB
choker/necklace_51.png DELETED

Git LFS Details

  • SHA256: 9dde33a771e25a88e557424398338ea716204296226666415bc74ec5427f28f3
  • Pointer size: 132 Bytes
  • Size of remote file: 1.45 MB
choker/necklace_56.png DELETED

Git LFS Details

  • SHA256: dbea04055e9b9e6f0ee2d0b17f74d4ccbe93978d7fdd343c494952dbac8c6ddd
  • Pointer size: 132 Bytes
  • Size of remote file: 1.08 MB
choker/necklace_8.png DELETED

Git LFS Details

  • SHA256: 459cd27ed9dc50834a3e89d9caa0d5bc640fdf6130f4355e93a292df0dc1ef37
  • Pointer size: 132 Bytes
  • Size of remote file: 1.5 MB
long_haram/necklace_1.png DELETED
Binary file (408 kB)
 
long_haram/necklace_10.png DELETED
Binary file (665 kB)
 
long_haram/necklace_2.png DELETED
Binary file (642 kB)
 
long_haram/necklace_3.png DELETED
Binary file (821 kB)
 
long_haram/necklace_4.png DELETED
Binary file (620 kB)
 
long_haram/necklace_5.png DELETED
Binary file (666 kB)
 
long_haram/necklace_6.png DELETED
Binary file (707 kB)
 
long_haram/necklace_7.png DELETED
Binary file (561 kB)
 
long_haram/necklace_8.png DELETED
Binary file (808 kB)
 
long_haram/necklace_9.png DELETED

Git LFS Details

  • SHA256: 3c104be6eb8e1a0a7854bbcf7d5662aa54365e7661b0d9e4e2a8521f88b31256
  • Pointer size: 132 Bytes
  • Size of remote file: 1.06 MB