lichorosario commited on
Commit
4c319af
1 Parent(s): 89b7584

Refactor app.py to handle trigger word and style prompt

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -59,10 +59,10 @@ def infer(selected_index, prompt, style_prompt, inf_steps, guidance_scale, width
59
  weight_name = result.result()[2]['value']
60
 
61
  if trigger_word and prompt.startswith(trigger_word):
62
- prompt = prompt[len(trigger_word):].lstrip()
63
 
64
- if style_prompt and prompt.startswith(style_prompt):
65
- prompt = prompt[len(style_prompt):].lstrip()
66
 
67
  prompt_arr = [trigger_word, prompt, style_prompt]
68
  prompt = '. '.join([element.strip() for element in prompt_arr if element.strip() != ''])
 
59
  weight_name = result.result()[2]['value']
60
 
61
  if trigger_word and prompt.startswith(trigger_word):
62
+ prompt = prompt[len(trigger_word+'. '):].lstrip()
63
 
64
+ if style_prompt and prompt.endswith(style_prompt):
65
+ prompt = prompt[:-len('. '+style_prompt)].rstrip()
66
 
67
  prompt_arr = [trigger_word, prompt, style_prompt]
68
  prompt = '. '.join([element.strip() for element in prompt_arr if element.strip() != ''])