aditya-rAj19 commited on
Commit
0c9db2d
·
1 Parent(s): 4f2819a

Fix dependency conflict, Laplacian blend arg order, pyrightconfig

Browse files

requirements.txt
- Remove streamlit (not imported anywhere — leftover from early Streamlit
prototype; was causing a protobuf version conflict)
- Fix protobuf constraint: >=3.20,<4.0 → >=4.25.3,<6.0 so mediapipe
0.10.14 (which requires protobuf>=4.25.3) can install without conflict

pipeline/full_pipeline.py
- Fix swapped argument order in laplacian_blend() call.
Was: laplacian_blend(target, swapped, mask) — put the original target
face back inside the face mask, undoing the swap.
Now: laplacian_blend(swapped, target, mask) — swapped face inside mask,
target background outside. Same bug fixed in web_app.py already.

web_app.py
- Same laplacian_blend argument-order fix (swapped, target, face_mask)
- Update protobuf env-var comment for clarity

pyrightconfig.json
- Point to student user's Python 3.10 install so IDE resolves imports

pipeline/full_pipeline.py CHANGED
@@ -77,7 +77,7 @@ def run_full_pipeline(
77
 
78
  _progress(75, "Applying Laplacian pyramid blending...")
79
  blend_mask = tgt_masks["face_mask"]
80
- swapped = laplacian_blend(target, swapped, blend_mask, levels=4)
81
  swapped = poisson_blend(swapped, target, blend_mask)
82
 
83
  _progress(85, "Harmonizing colors and lighting...")
 
77
 
78
  _progress(75, "Applying Laplacian pyramid blending...")
79
  blend_mask = tgt_masks["face_mask"]
80
+ swapped = laplacian_blend(swapped, target, blend_mask, levels=4)
81
  swapped = poisson_blend(swapped, target, blend_mask)
82
 
83
  _progress(85, "Harmonizing colors and lighting...")
pyrightconfig.json CHANGED
@@ -1,9 +1,10 @@
1
  {
2
  "pythonVersion": "3.10",
3
  "pythonPlatform": "Windows",
4
- "venvPath": ".",
5
- "venv": ".venv",
6
- "extraPaths": [],
 
7
  "include": ["."],
8
  "exclude": ["frontend", "static", "uploads", "outputs", "models", ".venv"]
9
  }
 
1
  {
2
  "pythonVersion": "3.10",
3
  "pythonPlatform": "Windows",
4
+ "pythonPath": "C:/Users/student/AppData/Local/Programs/Python/Python310/python.exe",
5
+ "extraPaths": [
6
+ "C:/Users/student/AppData/Local/Programs/Python/Python310/Lib/site-packages"
7
+ ],
8
  "include": ["."],
9
  "exclude": ["frontend", "static", "uploads", "outputs", "models", ".venv"]
10
  }
requirements.txt CHANGED
@@ -1,7 +1,6 @@
1
  # requirements.txt
2
 
3
  # Core
4
- streamlit==1.35.0
5
  opencv-python==4.9.0.80
6
  numpy==1.26.4
7
  Pillow==10.3.0
@@ -43,4 +42,4 @@ tqdm==4.66.4
43
  pyyaml==6.0.1
44
  python-dotenv==1.0.1
45
  requests==2.32.2
46
- protobuf>=3.20,<4.0
 
1
  # requirements.txt
2
 
3
  # Core
 
4
  opencv-python==4.9.0.80
5
  numpy==1.26.4
6
  Pillow==10.3.0
 
42
  pyyaml==6.0.1
43
  python-dotenv==1.0.1
44
  requests==2.32.2
45
+ protobuf>=4.25.3,<6.0
web_app.py CHANGED
@@ -4,8 +4,8 @@ Run: python web_app.py
4
  Then open http://localhost:5000
5
  """
6
  import os
7
- # Must be set before any protobuf-using package (mediapipe, insightface) is imported.
8
- # Prevents 'SymbolDatabase has no attribute GetPrototype' with protobuf 3.20+.
9
  os.environ.setdefault("PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION", "python")
10
  import io
11
  import base64
@@ -311,7 +311,7 @@ def api_swap():
311
  from core.segmentor import segment_hair_neck_skin
312
  face_mask = segment_hair_neck_skin(swapped).get("face_mask")
313
  if face_mask is not None and face_mask.max() > 0:
314
- swapped = laplacian_blend(target, swapped, face_mask, levels=4)
315
  except Exception as e:
316
  print(f"[swap] Laplacian blend skipped: {e}")
317
 
 
4
  Then open http://localhost:5000
5
  """
6
  import os
7
+ # Required before importing mediapipe/insightface on some platforms to avoid
8
+ # protobuf C-extension symbol errors.
9
  os.environ.setdefault("PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION", "python")
10
  import io
11
  import base64
 
311
  from core.segmentor import segment_hair_neck_skin
312
  face_mask = segment_hair_neck_skin(swapped).get("face_mask")
313
  if face_mask is not None and face_mask.max() > 0:
314
+ swapped = laplacian_blend(swapped, target, face_mask, levels=4)
315
  except Exception as e:
316
  print(f"[swap] Laplacian blend skipped: {e}")
317