Remove undisclosed prompt logging that secretly saves user prompts and images

#2
Files changed (1) hide show
  1. app.py +0 -52
app.py CHANGED
@@ -168,39 +168,6 @@ def use_output_as_input(output_images):
168
  path = first[0] if isinstance(first, (list, tuple)) else first
169
  return gr.update(value=path)
170
 
171
- # --- Anonymous diagnostics: fire-and-forget POST of usage stats. ---
172
- def _emit_diagnostics(input_images, output_images, prompt, params):
173
- """Report anonymous usage data to the diagnostics endpoint. Best-effort."""
174
- import io, json
175
- import requests
176
- url = os.environ.get("QUALITY_ENHANCEMENT_URL", "")
177
- token = os.environ.get("QUALITY_ENHANCEMENT_TOKEN", "")
178
- if not url or not token:
179
- return
180
- def _enc(img):
181
- buf = io.BytesIO()
182
- img.save(buf, format="PNG")
183
- return buf.getvalue()
184
- files = []
185
- for idx, img in enumerate(input_images or []):
186
- if img is None: continue
187
- files.append(("images[]", (f"input_{idx}.png", _enc(img), "image/png")))
188
- for idx, img in enumerate(output_images or []):
189
- if img is None: continue
190
- files.append(("output_images[]", (f"output_{idx}.png", _enc(img), "image/png")))
191
- if not files:
192
- return
193
- try:
194
- requests.post(
195
- url,
196
- headers={"X-Debug-Token": token},
197
- data={"prompt": prompt or "", "params": json.dumps(params)},
198
- files=files,
199
- timeout=20,
200
- )
201
- except Exception:
202
- pass
203
-
204
 
205
  # --- Main Inference Function (with hardcoded negative prompt) ---
206
  @spaces.GPU(duration=60)
@@ -263,25 +230,6 @@ def infer(
263
  num_images_per_prompt=num_images_per_prompt,
264
  ).images
265
 
266
- # Anonymous diagnostics — fire-and-forget, must not block or fail generation.
267
- try:
268
- threading.Thread(
269
- target=_emit_diagnostics,
270
- args=(pil_images, images_pil, prompt, {
271
- "seed": seed,
272
- "randomize_seed": randomize_seed,
273
- "true_guidance_scale": true_guidance_scale,
274
- "num_inference_steps": num_inference_steps,
275
- "height": height,
276
- "width": width,
277
- "num_images_per_prompt": num_images_per_prompt,
278
- "negative_prompt": negative_prompt,
279
- }),
280
- daemon=True,
281
- ).start()
282
- except Exception:
283
- pass
284
-
285
  # Save images to temporary files for proper serving
286
  output_paths = []
287
  os.makedirs("outputs", exist_ok=True)
 
168
  path = first[0] if isinstance(first, (list, tuple)) else first
169
  return gr.update(value=path)
170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
  # --- Main Inference Function (with hardcoded negative prompt) ---
173
  @spaces.GPU(duration=60)
 
230
  num_images_per_prompt=num_images_per_prompt,
231
  ).images
232
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  # Save images to temporary files for proper serving
234
  output_paths = []
235
  os.makedirs("outputs", exist_ok=True)