Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -121,7 +121,7 @@ def compute_prompt_match(image: Image.Image, prompt: str) -> float:
|
|
| 121 |
return 0.0
|
| 122 |
|
| 123 |
# --- Main prediction logic ---
|
| 124 |
-
def detect_with_model(image: Image.Image, prompt: str, username: str,
|
| 125 |
if not username.strip():
|
| 126 |
return "Please enter your name.", None, [], gr.update(visible=True), gr.update(visible=False), username
|
| 127 |
|
|
@@ -144,11 +144,11 @@ def detect_with_model(image: Image.Image, prompt: str, username: str, model: str
|
|
| 144 |
score = 1 if prediction == "Real" else 0
|
| 145 |
|
| 146 |
message = f"π Prediction: {prediction} ({confidence}% confidence)\nπ§ Prompt match: {round(prompt_score, 2)}%"
|
| 147 |
-
if prediction == "Real" and
|
| 148 |
leaderboard_scores[username] = leaderboard_scores.get(username, 0) + score
|
| 149 |
message += "\nπ Nice! You fooled the AI. +1 point!"
|
| 150 |
else:
|
| 151 |
-
if
|
| 152 |
message += "\n You uploaded a real image, this does not count toward the leaderboard!"
|
| 153 |
else:
|
| 154 |
message += "\nπ
The AI caught you this time. Try again!"
|
|
|
|
| 121 |
return 0.0
|
| 122 |
|
| 123 |
# --- Main prediction logic ---
|
| 124 |
+
def detect_with_model(image: Image.Image, prompt: str, username: str, model_name: str):
|
| 125 |
if not username.strip():
|
| 126 |
return "Please enter your name.", None, [], gr.update(visible=True), gr.update(visible=False), username
|
| 127 |
|
|
|
|
| 144 |
score = 1 if prediction == "Real" else 0
|
| 145 |
|
| 146 |
message = f"π Prediction: {prediction} ({confidence}% confidence)\nπ§ Prompt match: {round(prompt_score, 2)}%"
|
| 147 |
+
if prediction == "Real" and model_name.lower() != "real":
|
| 148 |
leaderboard_scores[username] = leaderboard_scores.get(username, 0) + score
|
| 149 |
message += "\nπ Nice! You fooled the AI. +1 point!"
|
| 150 |
else:
|
| 151 |
+
if model_name.lower() == "real":
|
| 152 |
message += "\n You uploaded a real image, this does not count toward the leaderboard!"
|
| 153 |
else:
|
| 154 |
message += "\nπ
The AI caught you this time. Try again!"
|