|
|
|
|
|
""" |
|
|
Script to deploy the Watermark Leaderboard to Hugging Face Spaces |
|
|
""" |
|
|
|
|
|
import os |
|
|
import shutil |
|
|
import json |
|
|
from pathlib import Path |
|
|
|
|
|
def copy_files_to_hf_directory(): |
|
|
"""Copy necessary files to the Hugging Face deployment directory""" |
|
|
|
|
|
|
|
|
source_dir = Path("../") |
|
|
hf_dir = Path(".") |
|
|
|
|
|
|
|
|
files_to_copy = [ |
|
|
"app.py", |
|
|
"requirements.txt", |
|
|
"README.md", |
|
|
"leaderboard.json" |
|
|
] |
|
|
|
|
|
|
|
|
reproducibility_source = source_dir / "Reproducibility" |
|
|
if reproducibility_source.exists(): |
|
|
reproducibility_dest = hf_dir / "Reproducibility" |
|
|
if reproducibility_dest.exists(): |
|
|
shutil.rmtree(reproducibility_dest) |
|
|
shutil.copytree(reproducibility_source, reproducibility_dest) |
|
|
print("β
Copied Reproducibility folder") |
|
|
|
|
|
|
|
|
for file_name in files_to_copy: |
|
|
source_file = source_dir / file_name |
|
|
dest_file = hf_dir / file_name |
|
|
|
|
|
if source_file.exists(): |
|
|
shutil.copy2(source_file, dest_file) |
|
|
print(f"β
Copied {file_name}") |
|
|
else: |
|
|
print(f"β οΈ {file_name} not found in source directory") |
|
|
|
|
|
print("\nπ Files copied successfully!") |
|
|
print("\nNext steps:") |
|
|
print("1. Create a new Hugging Face Space") |
|
|
print("2. Upload all files in this directory") |
|
|
print("3. Set the Space to use Gradio SDK") |
|
|
print("4. Your leaderboard will be live!") |
|
|
|
|
|
def create_hf_readme(): |
|
|
"""Create a Hugging Face specific README""" |
|
|
readme_content = """--- |
|
|
title: Watermark Leaderboard |
|
|
emoji: π |
|
|
colorFrom: blue |
|
|
colorTo: green |
|
|
sdk: gradio |
|
|
sdk_version: "4.44.0" |
|
|
app_file: app.py |
|
|
pinned: false |
|
|
license: mit |
|
|
short_description: Interactive leaderboard for watermark performance evaluation |
|
|
--- |
|
|
|
|
|
# Watermark Leaderboard π |
|
|
|
|
|
An interactive leaderboard for comparing watermark performance across different models and evaluation settings. |
|
|
|
|
|
## Features |
|
|
|
|
|
- **Interactive Scatter Plot**: Visualize watermark performance with Plotly charts |
|
|
- **Performance Table**: Detailed metrics with sorting and filtering |
|
|
- **Multiple Evaluation Settings**: Attack-free, Watermark Removal, and Stealing Attack |
|
|
- **Model Support**: LLaMA3 and DeepSeek models |
|
|
- **Dynamic Filtering**: Real-time updates based on model and metric selection |
|
|
- **Flexible Submissions**: Submit data for any combination of attack types |
|
|
- **Pending Approval System**: All submissions reviewed before appearing on leaderboard |
|
|
- **Complete Field Visibility**: Administrators see all submission details for review |
|
|
- **Professional UI**: Clean, modern interface with accordion sections |
|
|
- **Reproducibility**: Access to all evaluation codes and guidelines |
|
|
|
|
|
## How to Use |
|
|
|
|
|
1. **Select Model**: Choose between LLaMA3 or DeepSeek |
|
|
2. **Choose Setting**: Pick from Attack-free, Watermark Removal, or Stealing Attack |
|
|
3. **View Results**: Explore the scatter plot and detailed table |
|
|
4. **Submit Data**: Click "Add Your Data" to submit new results |
|
|
- Submit any combination of attack types (Attack-free, Watermark Removal, Stealing Attack) |
|
|
- All submissions go through approval process before appearing on leaderboard |
|
|
5. **Administrator Review**: Administrators can review pending submissions with full field visibility |
|
|
|
|
|
## Metrics Explained |
|
|
|
|
|
- **Normalized Utility β**: Higher values indicate better text quality |
|
|
- **Detection Rate (%) β**: Higher values indicate better watermark detection |
|
|
- **Absolute Utility Degradation β**: Higher values indicate better resistance to removal attacks |
|
|
- **Adversary BERT Score β**: Higher values indicate better performance under adversarial conditions |
|
|
|
|
|
## Contributing |
|
|
|
|
|
We encourage researchers to contribute their evaluation results. Please follow the guidelines in the "Guidelines" section for submission requirements. |
|
|
|
|
|
## License |
|
|
|
|
|
MIT License |
|
|
|
|
|
--- |
|
|
*Last updated: December 2024* |
|
|
""" |
|
|
|
|
|
with open("README.md", "w", encoding="utf-8") as f: |
|
|
f.write(readme_content) |
|
|
|
|
|
print("β
Created Hugging Face README.md") |
|
|
|
|
|
def main(): |
|
|
"""Main deployment function""" |
|
|
print("π Preparing Watermark Leaderboard for Hugging Face deployment...") |
|
|
|
|
|
|
|
|
create_hf_readme() |
|
|
|
|
|
|
|
|
copy_files_to_hf_directory() |
|
|
|
|
|
print("\nπ Deployment Checklist:") |
|
|
print("β
All files prepared") |
|
|
print("β
Requirements.txt updated") |
|
|
print("β
README.md created for Hugging Face") |
|
|
print("β
Reproducibility codes included") |
|
|
|
|
|
print("\nπ Ready for Hugging Face Spaces deployment!") |
|
|
|
|
|
if __name__ == "__main__": |
|
|
main() |
|
|
|