import os import gradio as gr import json from gradio_client import Client, handle_file backend = Client(os.getenv("BACKEND"), hf_token=os.getenv("TOKEN")) JS_FUNC1 = os.getenv("JS_FUNC1") JS_FUNC2 = os.getenv("JS_FUNC2") def detect(image): try: file_1 = handle_file(image) except Exception as e: gr.Info("Please upload an image file.") return "", "", "" result_text = backend.predict( image=handle_file(image), api_name="/detect" ) result = json.loads(result_text) if result and result["status"] == "ok": return result["overall"], result["aigen"], result["deepfake"] else: raise gr.Error("Error in processing image") custom_css = """ .button-gradient { background: linear-gradient(45deg, #ff416c, #ff4b2b, #ff9b00, #ff416c); background-size: 400% 400%; border: none; padding: 14px 28px; font-size: 16px; font-weight: bold; color: white; border-radius: 10px; cursor: pointer; transition: 0.3s ease-in-out; animation: gradientAnimation 2s infinite linear; box-shadow: 0 4px 10px rgba(255, 65, 108, 0.6); } @keyframes gradientAnimation { 0% { background-position: 0% 50%; } 25% { background-position: 50% 100%; } 50% { background-position: 100% 50%; } 75% { background-position: 50% 0%; } 100% { background-position: 0% 50%; } } .button-gradient:hover { transform: scale(1.05); box-shadow: 0 6px 15px rgba(255, 75, 43, 0.8); } """ MARKDOWN0 = """ # DeepFake Detector - ❤️Like above if this space helps #### [Learn more about our Deepfake Detection.](https://faceonlive.com/deepfake-detector) """ MARKDOWN3 = """