From f331b53ac151def2e047457c6d16b654a42533fd Mon Sep 17 00:00:00 2001 From: TitasDas Date: Tue, 30 May 2023 00:37:43 +0530 Subject: [PATCH] Add a preview feature to view the face image and input video once uploaded --- core/__pycache__/__init__.cpython-38.pyc | Bin 0 -> 137 bytes core/__pycache__/config.cpython-38.pyc | Bin 0 -> 714 bytes core/__pycache__/globals.cpython-38.pyc | Bin 0 -> 221 bytes core/__pycache__/processor.cpython-38.pyc | Bin 0 -> 1220 bytes core/__pycache__/utils.cpython-38.pyc | Bin 0 -> 2481 bytes run.py | 38 ++++++++++++++++++++-- 6 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 core/__pycache__/__init__.cpython-38.pyc create mode 100644 core/__pycache__/config.cpython-38.pyc create mode 100644 core/__pycache__/globals.cpython-38.pyc create mode 100644 core/__pycache__/processor.cpython-38.pyc create mode 100644 core/__pycache__/utils.cpython-38.pyc diff --git a/core/__pycache__/__init__.cpython-38.pyc b/core/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6b3e7c43b481a129c8cc9b73faf9ff09e6c717e6 GIT binary patch literal 137 zcmWIL<>g`kf=gdZQka4CV-N=!FakLaKwQiMBvKfH88jLFRx%WUgb~CqJ!h+!(Bjmh z;+PPZ7?;%I?2`O~nDG3f?3ki_AS*e)C^aTNJ~J<~BtBlRpz;=nO>TZlX-=vg$ehnW G%m4tx#2>x@ literal 0 HcmV?d00001 diff --git a/core/__pycache__/config.cpython-38.pyc b/core/__pycache__/config.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..948f2fdc27be6fdc3689e821409d307f76d74342 GIT binary patch literal 714 zcmY*XJ#X7E5WS;hTmDLi6amtIAfWKrp)iaVNdt88;s$920|G75u4GvhC_1nW7s!w` zTYo@1_V0A$+9`9hV4bqEx2u&Zpg`kf=gdZQlf$MV-N=!FabFZKwK;VBvKes7;_k+7*d#`7*iP*FfC+=VoqTU zX3%7Q36y2@t0*eXE6L1Fjbbk?PK{45D2)Hq)$ literal 0 HcmV?d00001 diff --git a/core/__pycache__/processor.cpython-38.pyc b/core/__pycache__/processor.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0b64d39912127bb7f2ee55aad0656ed39ccbcde1 GIT binary patch literal 1220 zcmY*ZOOF#r5bo-E&)CaiNQgod<>~{w3Q{B#MF@#S;t=hHMZn0BGq`)bV~=Ns?luo= z%w;)d{{aW~$b}!nv9CGt10qG7Qq?wMGgg1q^_ZEe@9Xiyem`Y+ef-CWe|^UOCgZun6-IsK%?JMV!aLB+QaoDtzhBvRO|AXFTtV zP(*K7z9V9hpuHsE0UM^D@Gb0c2sWNdGd?aRlJ-i;w!-~tP}cfI(Y8{Jf4+HZuc_;o zm`_^OJTHY*dcx`c?G>ZVaNWhFKOh)p;2rPSIh?|pcW}V|_-pOCn0F3qfAzazosYSo z3)IMXGr#k@pyL7rKl9fiRtBBdh36cY356$o%mim1uzCmm@T>obJsbGUMDtX=1-6cW ztp->TU99*8DOyLbqsQzCRzJpt6(Hg>Ao7rmH*LN*2QQh{W-hHR~a*HYyh{RB5CQT2zA+%~IhV%}k-_n;IXy8>#f-izwX98v!uCj_y=m1vEh=q& z@@(c}lcqi{r<+5Uy2#R$m39;4$)XXm8n2orPpEO{+GzV6MSm=tp{YC9%7qc!Fm8_c ZH@tCK$=gJrCPrdxoqj#&@vB~Z`9JN=Dp&vj literal 0 HcmV?d00001 diff --git a/core/__pycache__/utils.cpython-38.pyc b/core/__pycache__/utils.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..221efb20d9393c10537fa1b262afcae178bf44ad GIT binary patch literal 2481 zcmZ`*Pj4GV6rb6DUfW3;($F>q!D32<0Vin{^$;}(sg=0-Qc%INur{7?vWdOBnjJfh zwLY~+J^?5wIri&t+$*Pk04}+}@69@Cn!>E+&3ogW+4p;Y{o~?djbZ%xw-(>~jQvHz z)nP;U4l_$Z1QUG7I_1hcTv#1TvIAS#hn8vxr(+3Mc&}K;5qE?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L-{S)Ji80xbKi1!jXSpQ)m*>syXIN&?SBC_Y%ACR literal 0 HcmV?d00001 diff --git a/run.py b/run.py index df34d56..e36b9d0 100644 --- a/run.py +++ b/run.py @@ -22,6 +22,8 @@ from core.config import get_face import webbrowser import psutil import cv2 +import threading +from PIL import Image, ImageTk pool = None args = {} @@ -59,13 +61,45 @@ def start_processing(): pool.join() +def preview_image(image_path): + img = Image.open(image_path) + img = img.resize((150, 150), Image.ANTIALIAS) + photo_img = ImageTk.PhotoImage(img) + left_frame = tk.Frame(window) + left_frame.pack(side=tk.LEFT, padx=10, pady=10) + img_label = tk.Label(left_frame, image=photo_img) + img_label.image = photo_img + img_label.pack() + + +def preview_video(video_path): + cap = cv2.VideoCapture(video_path) + if not cap.isOpened(): + print("Error opening video file") + return + ret, frame = cap.read() + if ret: + frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) + img = Image.fromarray(frame) + img = img.resize((150, 150), Image.ANTIALIAS) + photo_img = ImageTk.PhotoImage(img) + right_frame = tk.Frame(window) + right_frame.pack(side=tk.RIGHT, padx=10, pady=10) + img_label = tk.Label(right_frame, image=photo_img) + img_label.image = photo_img + img_label.pack() + + cap.release() + + def select_face(): args['source_img'] = filedialog.askopenfilename(title="Select a face") + preview_image(args['source_img']) def select_target(): args['target_path'] = filedialog.askopenfilename(title="Select a target") - + threading.Thread(target=preview_video, args=(args['target_path'],)).start() def toggle_fps_limit(): args['keep_fps'] = limit_fps.get() != True @@ -120,7 +154,7 @@ if __name__ == "__main__": start() quit() window = tk.Tk() - window.geometry("600x200") + window.geometry("600x350") window.title("roop") # Contact information