Spaces:
Running
Running
Commit ·
6a28782
1
Parent(s): 37ea042
Update app.py
Browse files1234511 unmodified lines1718192021222324252627287 unmodified lines36373839404111 unmodified lines5354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107import gradio as grimport gradioimport subprocess as spimport os11 unmodified linesframe_processor = rest_args[0]selected_frame_processors = ' '.join(frame_processor)cmd = f"python run.py --execution-providers cpu -s {source} -t {target} -o {output} --frame-processors {selected_frame_processors}"if len(rest_args) > 1:skip_audio = rest_args[1]keep_fps = rest_args[2]keep_temp = rest_args[3]if skip_audio:cmd += " --skip-audio"if keep_fps:7 unmodified linesreturn outputexcept Exception as e:return f"An error occurred: {str(e)}"def get_theme() -> gr.Theme:return gr.themes.Soft(11 unmodified linesgr.HTML('<center><a href="codegenius.me">DeepFakeAI 1.0.0</a></center>')with gr.Box():frame_processor_checkbox = gr.CheckboxGroup(choices = ['face_swapper', 'face_enhancer', 'frame_enhancer'],label = 'FRAME PROCESSORS',value = ['face_swapper'] # Default value)with gr.Tab("Image:"):source_image = gr.Image(type="filepath", label="Source Image")target_image = gr.Image(type="filepath", label="Target Image")image_button = gr.Button("Start")image_output = gr.Image()image_button.click(run,inputs=[source_image, target_image, frame_processor_checkbox],outputs=image_output)with gr.Tab("Video:"):source_image_video = gr.Image(type="filepath", label="Source Image")target_video = gr.Video(label="Target Video")with gr.Box():skip_audio = gr.Checkbox(label="SKIP AUDIO")keep_fps = gr.Checkbox(label="KEEP FPS")keep_temp = gr.Checkbox(label="KEEP TEMP")video_button = gr.Button("Start")video_output = gr.Video()video_button.click(run,inputs=[source_image_video, target_video, frame_processor_checkbox, skip_audio, keep_fps, keep_temp],outputs=video_output)# Additional UI components ...with gr.Box():face_analyser_direction_dropdown = gr.Dropdown(label = 'Face Analyser Direction',choices = ['left-right', 'right-left', 'top-bottom', 'bottom-top', 'small-large', 'large-small'],value = 'left-right')face_analyser_age_dropdown = gr.Dropdown(label = 'Face Analyser Age',choices = ['none'] + ['child', 'young', 'adult', 'old'],value = 'none')face_analyser_gender_dropdown = gr.Dropdown(label = 'Face Analyser Gender',choices = ['none'] + ['male', 'female'],value = 'none')ui.launch(debug=True)123411 unmodified lines161718192021222324252627282930313233343536377 unmodified lines4546474849505152535455565711 unmodified lines69707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127import gradio as grimport subprocess as spimport os11 unmodified linesframe_processor = rest_args[0]selected_frame_processors = ' '.join(frame_processor)face_analyser_direction = rest_args[1]face_analyser_age = rest_args[2]face_analyser_gender = rest_args[3]cmd = (f"python run.py --execution-providers cuda -s {source} -t {target} -o {output} "f"--frame-processors {selected_frame_processors} "f"--face-analyser-direction {face_analyser_direction} "f"--face-analyser-age {face_analyser_age} "f"--face-analyser-gender {face_analyser_gender}")if len(rest_args) > 4:skip_audio = rest_args[4]keep_fps = rest_args[5]keep_temp = rest_args[6]if skip_audio:cmd += " --skip-audio"if keep_fps:7 unmodified linesreturn outputexcept Exception as e:return f"An error occurred: {str(e)}"def clear_output(output):if os.path.exists(output):os.remove(output)return "Output file deleted"else:return "Output file does not exist"def get_theme() -> gr.Theme:return gr.themes.Soft(11 unmodified linesgr.HTML('<center><a href="codegenius.me">DeepFakeAI 1.0.0</a></center>')with gr.Box():with gr.Column(scale=3):frame_processor_checkbox = gr.CheckboxGroup(choices = ['face_swapper', 'face_enhancer', 'frame_enhancer'],label = 'FRAME PROCESSORS',value = ['face_swapper'] # Default value)with gr.Box():with gr.Column(scale=3):face_analyser_direction_dropdown = gr.Dropdown(label = 'FACE ANALYSER DIRECTION',choices = ['left-right', 'right-left', 'top-bottom', 'bottom-top', 'small-large', 'large-small'],value = 'left-right')face_analyser_age_dropdown = gr.Dropdown(label = 'FACE ANALYSER AGE',choices = ['none'] + ['child', 'young', 'adult', 'old'],value = 'none')face_analyser_gender_dropdown = gr.Dropdown(label = 'FACE ANALYSER GENDER',choices = ['none'] + ['male', 'female'],value = 'none')with gr.Tab("Image: "):source_image = gr.Image(type="filepath", label="SOURCE IMAGE")target_image = gr.Image(type="filepath", label="TARGET IMAGE")image_button = gr.Button("START")clear_button = gr.Button("CLEAR")image_output = gr.Image(label="OUTPUT")image_button.click(run,inputs=[source_image, target_image, frame_processor_checkbox, face_analyser_direction_dropdown, face_analyser_age_dropdown, face_analyser_gender_dropdown],outputs=image_output)clear_button.click(clear_output, inputs=[image_output])with gr.Tab("Video: "):source_image_video = gr.Image(type="filepath", label="SOURCE IMAGE")target_video = gr.Video(label="TARGET VIDEO")with gr.Box():skip_audio = gr.Checkbox(label="SKIP AUDIO")keep_fps = gr.Checkbox(label="KEEP FPS")keep_temp = gr.Checkbox(label="KEEP TEMP")video_button = gr.Button("START")clear_video_button = gr.Button("CLEAR")video_output = gr.Video(label="OUTPUT")video_button.click(run,inputs=[source_image_video, target_video, frame_processor_checkbox, face_analyser_direction_dropdown, face_analyser_age_dropdown, face_analyser_gender_dropdown, skip_audio, keep_fps, keep_temp],outputs=video_output)clear_video_button.click(clear_output, inputs=[video_output])ui.launch(debug=True)
app.py+58-38