Jannat24 commited on
Commit
49e868c
·
verified ·
1 Parent(s): 4c800ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -15
app.py CHANGED
@@ -5,7 +5,6 @@ import shutil
5
  import requests
6
  import numpy as np
7
  from PIL import Image, ImageOps
8
- import cv2
9
  import math
10
  import matplotlib.pyplot as plt
11
  import pickle
@@ -44,20 +43,7 @@ def gen_sources(deepfake_img):
44
  #----------------DeepFake Face Segmentation-----------------
45
  ##----------------------Initialize:Face Segmentation----------------------------------
46
  segmenter = FaceSegmenter(threshold=0.5)
47
- #Convert Pillow Image to OpenCV Image (BGR format)
48
- dfcv2_image = np.array(deepfake_img) # Convert PIL to numpy array (RGB)
49
- dfcv2_image = cv2.cvtColor(dfcv2_image, cv2.COLOR_RGB2BGR) # Convert RGB to BGR
50
- deepfake_seg = segmenter.segment_face(dfcv2_image)
51
- # Save PIL Image to temporary file
52
- with tempfile.NamedTemporaryFile(suffix=".jpg", delete=False) as temp_file:
53
- temp_path = temp_file.name
54
- deepfake_img.save(temp_path, format="JPEG")
55
-
56
- # Segment face using the temporary file path
57
- try:
58
- deepfake_seg = segmenter.segment_face(temp_path)
59
- finally:
60
- os.remove(temp_path) # Clean up temporary file
61
 
62
  config_path = "./models/config.yaml"
63
  #------------Initialize:Decoder-F------------------------
 
5
  import requests
6
  import numpy as np
7
  from PIL import Image, ImageOps
 
8
  import math
9
  import matplotlib.pyplot as plt
10
  import pickle
 
43
  #----------------DeepFake Face Segmentation-----------------
44
  ##----------------------Initialize:Face Segmentation----------------------------------
45
  segmenter = FaceSegmenter(threshold=0.5)
46
+ deepfake_seg = segmenter.segment_face(deepfake_img)
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
  config_path = "./models/config.yaml"
49
  #------------Initialize:Decoder-F------------------------