directedbykobyperez commited on
Commit
a427ccd
·
verified ·
1 Parent(s): 9a4d607

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +37 -15
app.py CHANGED
@@ -33,6 +33,25 @@ SIZE_PRESETS = {
33
 
34
  pipe = None
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  def get_pipeline():
38
  global pipe
@@ -98,23 +117,26 @@ def generate(prompt, negative_prompt, size_preset, steps, seed, edit_image):
98
  png_path = os.path.join(OUT, f"{image_id}.png")
99
  image.save(png_path)
100
 
 
 
101
  words = (prompt or "").strip().replace("\n", " ").split()[:8]
102
  title = " ".join(words).title()[:80] if words else f"Qwen Image {image_id[:6]}"
103
- _upload_to_community(png_path, {
104
- "id": image_id,
105
- "title": title,
106
- "prompt": prompt or "",
107
- "negative_prompt": negative_prompt or "",
108
- "caption": (prompt or "").strip(),
109
- "width": width,
110
- "height": height,
111
- "steps": int(steps),
112
- "seed": seed,
113
- "mode": mode,
114
- "model": MODEL_ID,
115
- "image_file": f"{image_id}.png",
116
- "created_at": datetime.now(timezone.utc).isoformat(),
117
- }, image_id)
 
118
 
119
  return png_path, png_path, f"seed={seed} | {width}x{height} | {steps} steps | {mode}"
120
 
 
33
 
34
  pipe = None
35
 
36
+ # Flagged words: generation proceeds normally, but flagged results are NOT
37
+ # uploaded to the public community bucket. Silent, no user-facing warning.
38
+ FLAGGED = (
39
+ "naked", "nude", "nsfw", "porn", "pornographic", "hentai", "erotic",
40
+ "sex", "sexual", "undress", "unclothed", "topless", "bottomless",
41
+ "nak3d", "nudes", "bathing", "panties", "lingerie", "underwear",
42
+ "orgasm", "nipple", "nipples", "genital", "penis", "vagina", "boobs",
43
+ "titties", "incest", "rape",
44
+ "child", "kid ", "kids", "minor", "teen", "teenager", "underage",
45
+ "schoolgirl", "schoolboy", "loli", "shota", "toddler", "infant",
46
+ "小女孩", "小男孩", "少女", "儿童", "裸体", "裸足", "脱下", "脱掉",
47
+ "裸", "色情", "性爱", "幼女",
48
+ )
49
+
50
+
51
+ def is_flagged(*texts):
52
+ joined = " " + " ".join(t or "" for t in texts).lower() + " "
53
+ return any(w in joined for w in FLAGGED)
54
+
55
 
56
  def get_pipeline():
57
  global pipe
 
117
  png_path = os.path.join(OUT, f"{image_id}.png")
118
  image.save(png_path)
119
 
120
+ flagged = is_flagged(prompt, negative_prompt)
121
+
122
  words = (prompt or "").strip().replace("\n", " ").split()[:8]
123
  title = " ".join(words).title()[:80] if words else f"Qwen Image {image_id[:6]}"
124
+ if not flagged:
125
+ _upload_to_community(png_path, {
126
+ "id": image_id,
127
+ "title": title,
128
+ "prompt": prompt or "",
129
+ "negative_prompt": negative_prompt or "",
130
+ "caption": (prompt or "").strip(),
131
+ "width": width,
132
+ "height": height,
133
+ "steps": int(steps),
134
+ "seed": seed,
135
+ "mode": mode,
136
+ "model": MODEL_ID,
137
+ "image_file": f"{image_id}.png",
138
+ "created_at": datetime.now(timezone.utc).isoformat(),
139
+ }, image_id)
140
 
141
  return png_path, png_path, f"seed={seed} | {width}x{height} | {steps} steps | {mode}"
142