import gradio as gr from MMD_calculate import MMDMPDetector detector = MMDMPDetector() # Initialize your MMD-MP detector MINIMUM_TOKENS = 64 # Minimum number of tokens for detection def count_tokens(text): return len(text.split()) # Count the number of tokens (words) in the text def run_detector(input_text): # Check if input meets the token requirement if count_tokens(input_text) < MINIMUM_TOKENS: return f"Error: Text is too short! At least {MINIMUM_TOKENS} tokens are required." # Perform detection (replace this with your model's prediction logic) prediction = detector.predict(input_text) return f"Result: {prediction}" def change_mode(mode): if mode == "Low False Positive Rate": detector.set_mode("low-fpr") # Adjust detector mode elif mode == "High Accuracy": detector.set_mode("accuracy") return f"Mode set to: {mode}" css = """ .green { color: black!important; line-height:1.9em; padding: 0.2em 0.2em; background: #ccffcc; border-radius:0.5rem;} .red { color: black!important; line-height:1.9em; padding: 0.2em 0.2em; background: #ffad99; border-radius:0.5rem;} .hyperlinks { display: flex; align-items: center; justify-content: flex-end; padding: 12px; margin: 0 10px; text-decoration: none; color: #000; } """ with gr.Blocks(css=css, theme=gr.themes.Default(font=[gr.themes.GoogleFont("Inconsolata"), "Arial", "sans-serif"])) as app: # Header Row with gr.Row(): with gr.Column(scale=3): gr.HTML("