Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -154,11 +154,26 @@ def getadline(text_inp):
|
|
154 |
|
155 |
def getadvertisement(topic):
|
156 |
if topic!='':
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
else:
|
159 |
input_keyword=getadline(random.choice('abcdefghijklmnopqrstuvwxyz'))
|
160 |
-
|
161 |
-
|
162 |
print(input_keyword)
|
163 |
print(datetime.today().strftime("%d-%m-%Y"))
|
164 |
prompt_SD=input_keyword+','+prompt_image
|
|
|
154 |
|
155 |
def getadvertisement(topic):
|
156 |
if topic!='':
|
157 |
+
mainstring=topic
|
158 |
+
foundnsfw=0
|
159 |
+
for each_word in nsfwlowerlist:
|
160 |
+
raw_search_string = r"\b" + each_word + r"\b"
|
161 |
+
match_output = re.search(raw_search_string, mainstring)
|
162 |
+
no_match_was_found = ( match_output is None )
|
163 |
+
if no_match_was_found:
|
164 |
+
foundnsfw=0
|
165 |
+
else:
|
166 |
+
foundnsfw=1
|
167 |
+
print(each_word)
|
168 |
+
break
|
169 |
+
if foundnsfw==1:
|
170 |
+
topic="Unsafe content found. Please try again with different prompts."
|
171 |
+
print(topic)
|
172 |
+
input_keyword=topic
|
173 |
else:
|
174 |
input_keyword=getadline(random.choice('abcdefghijklmnopqrstuvwxyz'))
|
175 |
+
if 'Unsafe content found' in input_keyword:
|
176 |
+
input_keyword='Abstract art with a splash of colors'
|
177 |
print(input_keyword)
|
178 |
print(datetime.today().strftime("%d-%m-%Y"))
|
179 |
prompt_SD=input_keyword+','+prompt_image
|