Akshatha Arodi commited on
Commit
9487681
·
1 Parent(s): bce2657

Add timestamp and username

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -12,7 +12,7 @@ from huggingface_hub import HfApi
12
  from transformers import CLIPTokenizer, AutoImageProcessor, AutoModelForImageClassification
13
  from safetensors.torch import load_file as safe_load
14
  import subprocess
15
-
16
 
17
  # --- Config ---
18
  HUB_REPO_ID = "CDL-AMLRT/OpenArenaLeaderboard"
@@ -156,12 +156,12 @@ def detect_with_model(image: Image.Image, prompt: str, username: str, model_name
156
  image_filename = f"{image_id}.jpg"
157
  image_path = os.path.join(image_dir, image_filename)
158
  image.save(image_path)
159
-
160
 
161
 
162
  csv_path = os.path.join("test", "leaderboard_entries.csv")
163
- header = "file_name,prompt,label,model,split\n"
164
- csv_line = f"test/fake/{image_filename},\"{prompt}\",fake,{model_name},test\n"
165
  try:
166
  file_exists = os.path.exists(csv_path)
167
  with open(csv_path, "a", encoding="utf-8") as f:
@@ -227,8 +227,10 @@ with gr.Blocks(css=".gr-button {font-size: 16px !important}") as demo:
227
  username_input = gr.Textbox(label="Your Name", placeholder="Enter your name", interactive=True)
228
  model_input = gr.Textbox(label="Model used, specify the version (e.g., Imagen 3, Dall-e 3, Midjourney 6).", placeholder="Name of the model used to generate the image", interactive=True)
229
 
 
230
  with gr.Row():
231
  prompt_input = gr.Textbox(
 
232
  label="Prompt to use",
233
  placeholder="e.g., ...",
234
  value="",
 
12
  from transformers import CLIPTokenizer, AutoImageProcessor, AutoModelForImageClassification
13
  from safetensors.torch import load_file as safe_load
14
  import subprocess
15
+ import datetime
16
 
17
  # --- Config ---
18
  HUB_REPO_ID = "CDL-AMLRT/OpenArenaLeaderboard"
 
156
  image_filename = f"{image_id}.jpg"
157
  image_path = os.path.join(image_dir, image_filename)
158
  image.save(image_path)
159
+ current_time =
160
 
161
 
162
  csv_path = os.path.join("test", "leaderboard_entries.csv")
163
+ header = "file_name,prompt,label,model,split,user,timestamp\n"
164
+ csv_line = f"test/fake/{image_filename},\"{prompt}\",fake,{model_name},test,{username},{datetime.utcnow().isoformat()}\n"
165
  try:
166
  file_exists = os.path.exists(csv_path)
167
  with open(csv_path, "a", encoding="utf-8") as f:
 
227
  username_input = gr.Textbox(label="Your Name", placeholder="Enter your name", interactive=True)
228
  model_input = gr.Textbox(label="Model used, specify the version (e.g., Imagen 3, Dall-e 3, Midjourney 6).", placeholder="Name of the model used to generate the image", interactive=True)
229
 
230
+ # 🚫 Freeze this block: do not allow edits to the prompt input component's configuration.
231
  with gr.Row():
232
  prompt_input = gr.Textbox(
233
+ interactive=False,
234
  label="Prompt to use",
235
  placeholder="e.g., ...",
236
  value="",