phenomenon1981 commited on
Commit
0912eef
โ€ข
1 Parent(s): 1bd8763

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -14
app.py CHANGED
@@ -17,31 +17,27 @@ proc1=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
17
 
18
  def restart_script_periodically():
19
  while True:
20
- time.sleep(600) # 10 minutes
21
- try:
22
- os.execl(sys.executable, sys.executable, *sys.argv)
23
- except:
24
- pass
25
 
26
  restart_thread = Thread(target=restart_script_periodically, daemon=True)
27
  restart_thread.start()
28
 
 
29
  queue = Queue()
30
- queue_threshold = 800
31
 
32
- def add_random_noise(prompt, noise_level=0.00):
33
  if noise_level == 0:
34
- noise_level = 0.00
35
- # Get the percentage of characters to add as noise
36
  percentage_noise = noise_level * 5
37
- # Get the number of characters to add as noise
38
  num_noise_chars = int(len(prompt) * (percentage_noise/100))
39
- # Get the indices of the characters to add noise to
40
  noise_indices = random.sample(range(len(prompt)), num_noise_chars)
41
- # Add noise to the selected characters
42
  prompt_list = list(prompt)
43
- # Add numbers, special characters, and all emojis to the list of characters used to add noise
44
- noise_chars = string.ascii_letters + string.punctuation + ' ' + string.digits + emoji.emojize(":all:")
45
  for index in noise_indices:
46
  prompt_list[index] = random.choice(noise_chars)
47
  return "".join(prompt_list)
 
17
 
18
  def restart_script_periodically():
19
  while True:
20
+ random_time = random.randint(420, 600)
21
+ time.sleep(random_time)
22
+ os.execl(sys.executable, sys.executable, *sys.argv)
23
+
 
24
 
25
  restart_thread = Thread(target=restart_script_periodically, daemon=True)
26
  restart_thread.start()
27
 
28
+
29
  queue = Queue()
30
+ queue_threshold = 100
31
 
32
+ def add_random_noise(prompt, noise_level=0.07):
33
  if noise_level == 0:
34
+ noise_level = 0.07
 
35
  percentage_noise = noise_level * 5
 
36
  num_noise_chars = int(len(prompt) * (percentage_noise/100))
 
37
  noise_indices = random.sample(range(len(prompt)), num_noise_chars)
 
38
  prompt_list = list(prompt)
39
+ noise_chars = list(string.ascii_letters + string.punctuation + ' ' + string.digits)
40
+ noise_chars.extend(['๐Ÿ˜', '๐Ÿ’ฉ', '๐Ÿ˜‚', '๐Ÿค”', '๐Ÿ˜Š', '๐Ÿค—', '๐Ÿ˜ญ', '๐Ÿ™„', '๐Ÿ˜ท', '๐Ÿค”', '๐Ÿคฏ', '๐Ÿคซ', '๐Ÿฅด', '๐Ÿ˜ด', '๐Ÿคฉ', '๐Ÿฅณ', '๐Ÿ˜”', '๐Ÿ˜ฉ', '๐Ÿคฏ', '๐Ÿคช', '๐Ÿ˜‡', '๐Ÿคข', '๐Ÿ˜ท', '๐Ÿคฎ', '๐Ÿ˜ˆ', '๐Ÿ‘น', '๐Ÿ‘ป', '๐Ÿค–', '๐Ÿ‘ฝ', '๐Ÿ’€', '๐ŸŽƒ', '๐ŸŽ…', '๐ŸŽ„', '๐ŸŽ', '๐ŸŽ‚', '๐ŸŽ‰', '๐ŸŽˆ', '๐ŸŽŠ', '๐ŸŽฎ', 'โค๏ธ', '๐Ÿ’”', '๐Ÿ’•', '๐Ÿ’–', '๐Ÿ’—', '๐Ÿถ', '๐Ÿฑ', '๐Ÿญ', '๐Ÿน', '๐ŸฆŠ', '๐Ÿป', '๐Ÿจ', '๐Ÿฏ', '๐Ÿฆ', '๐Ÿ˜', '๐Ÿ”ฅ', '๐ŸŒง๏ธ', '๐ŸŒž', '๐ŸŒˆ', '๐Ÿ’ฅ', '๐ŸŒด', '๐ŸŒŠ', '๐ŸŒบ', '๐ŸŒป', '๐ŸŒธ', '๐ŸŽจ', '๐ŸŒ…', '๐ŸŒŒ'])
41
  for index in noise_indices:
42
  prompt_list[index] = random.choice(noise_chars)
43
  return "".join(prompt_list)