zenafey commited on
Commit
bed5126
·
1 Parent(s): e99b713

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -99,11 +99,12 @@ def remove_id_and_ext(text):
99
  return text
100
 
101
  def place_lora(current_prompt, lorabtn):
102
- if f"<lora:{lorabtn}:1.0>" in current_prompt:
103
- result = current_prompt.replace(f"<lora:{lorabtn}:1.0>", "")
104
- else:
105
- result = f"{current_prompt} <lora:{lorabtn}:1>"
106
- return result
 
107
 
108
  def create_grid(image_urls):
109
  # Download first image to get size
 
99
  return text
100
 
101
  def place_lora(current_prompt, lorabtn):
102
+ pattern = r"<lora:" + lora_name + r":.*?>"
103
+
104
+ if re.search(pattern, current_prompt):
105
+ return re.sub(pattern, "", current_prompt)
106
+ else:
107
+ return current_prompt + "<lora:" + lora_name + ":1>"
108
 
109
  def create_grid(image_urls):
110
  # Download first image to get size