ura23 commited on
Commit
f05d102
·
verified ·
1 Parent(s): 40964e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -6
app.py CHANGED
@@ -228,8 +228,18 @@ def main():
228
  filter_set = set(tag.strip().lower() for tag in filter_tags.split(","))
229
 
230
  # Parse custom tags
231
- custom_tag_set = set(tag.strip().lower() for tag in custom_tags.split(","))
232
 
 
 
 
 
 
 
 
 
 
 
233
  # Generate formatted output
234
  prompts = []
235
  for i, (general_tags, character_tags) in enumerate(results):
@@ -241,10 +251,12 @@ def main():
241
  tag.replace('_', ' ') for tag in general_tags if tag.lower() not in filter_set
242
  )
243
 
244
- # Check for missing custom tags
245
- missing_custom_tags = custom_tag_set - set(general_tags + character_tags)
246
- if missing_custom_tags:
247
- general_part += ", " + ", ".join(missing_custom_tags)
 
 
248
 
249
  # Construct the prompt based on the presence of character_part
250
  if character_part:
@@ -255,7 +267,6 @@ def main():
255
  # Join all prompts with blank lines
256
  return "\n\n".join(prompts)
257
 
258
-
259
  submit.click(
260
  process_images,
261
  inputs=[image_files, model_repo, general_thresh, character_thresh, filter_tags, custom_tags],
 
228
  filter_set = set(tag.strip().lower() for tag in filter_tags.split(","))
229
 
230
  # Parse custom tags
231
+ custom_tag_list = [tag.strip().lower() for tag in custom_tags.split(",")]
232
 
233
+ # Define the fallback tags for each custom tag
234
+ fallback_tags = {
235
+ "shy, happy": "smile",
236
+ "happy": "joy",
237
+ "cute": "adorable",
238
+ "energetic": "vibrant",
239
+ "blush": "flushed",
240
+ # Add more custom to fallback mappings as needed
241
+ }
242
+
243
  # Generate formatted output
244
  prompts = []
245
  for i, (general_tags, character_tags) in enumerate(results):
 
251
  tag.replace('_', ' ') for tag in general_tags if tag.lower() not in filter_set
252
  )
253
 
254
+ # Check for missing custom tags and apply corresponding fallback tags
255
+ for custom_tag in custom_tag_list:
256
+ if custom_tag not in (general_tags + character_tags):
257
+ # Append the corresponding fallback tag for the missing custom tag
258
+ if custom_tag in fallback_tags:
259
+ general_part += ", " + fallback_tags[custom_tag]
260
 
261
  # Construct the prompt based on the presence of character_part
262
  if character_part:
 
267
  # Join all prompts with blank lines
268
  return "\n\n".join(prompts)
269
 
 
270
  submit.click(
271
  process_images,
272
  inputs=[image_files, model_repo, general_thresh, character_thresh, filter_tags, custom_tags],