lalashechka commited on
Commit
9b9ddaf
1 Parent(s): bd92e40

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -10,18 +10,22 @@ import os
10
  from PIL import Image
11
  import io
12
  import base64
 
13
 
14
 
15
  def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
16
  result = {"prompt": prompt,"negative_prompt": negative_prompt,"task": task,"steps": steps,"sampler": sampler,"cfg_scale": cfg_scale,"seed": seed}
17
  print(result)
 
 
 
 
 
 
 
18
 
19
- language = detect(prompt)
20
 
21
- if language == 'ru':
22
- prompt = GoogleTranslator(source='ru', target='en').translate(prompt)
23
- print(prompt)
24
-
25
  cfg = int(cfg_scale)
26
  steps = int(steps)
27
  seed = int(seed)
@@ -65,8 +69,6 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
65
  return photo
66
 
67
 
68
-
69
-
70
  def flipp():
71
  if task == 'Stable Diffusion XL 1.0':
72
  model = 'sd_xl_base_1.0'
 
10
  from PIL import Image
11
  import io
12
  import base64
13
+ import re
14
 
15
 
16
  def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
17
  result = {"prompt": prompt,"negative_prompt": negative_prompt,"task": task,"steps": steps,"sampler": sampler,"cfg_scale": cfg_scale,"seed": seed}
18
  print(result)
19
+ try:
20
+ language = detect(prompt)
21
+ if language == 'ru':
22
+ prompt = GoogleTranslator(source='ru', target='en').translate(prompt)
23
+ print(prompt)
24
+ except:
25
+ pass
26
 
27
+ prompt = re.sub(r'[^a-zA-Zа-яА-Я\s]', '', prompt)
28
 
 
 
 
 
29
  cfg = int(cfg_scale)
30
  steps = int(steps)
31
  seed = int(seed)
 
69
  return photo
70
 
71
 
 
 
72
  def flipp():
73
  if task == 'Stable Diffusion XL 1.0':
74
  model = 'sd_xl_base_1.0'