Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -31,6 +31,21 @@ restart_thread.start()
|
|
31 |
queue = Queue()
|
32 |
queue_threshold = 100
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
def add_random_noise(prompt, noise_level=0.00):
|
35 |
if noise_level == 0:
|
36 |
noise_level = 0.00
|
@@ -43,16 +58,17 @@ def add_random_noise(prompt, noise_level=0.00):
|
|
43 |
for index in noise_indices:
|
44 |
prompt_list[index] = random.choice(noise_chars)
|
45 |
return "".join(prompt_list)
|
46 |
-
|
47 |
-
|
|
|
48 |
if noise_level == 0:
|
49 |
-
|
50 |
percentage_noise = noise_level * 5
|
51 |
num_noise_chars = int(len(prompt) * (percentage_noise/100))
|
52 |
noise_indices = random.sample(range(len(prompt)), num_noise_chars)
|
53 |
prompt_list = list(prompt)
|
54 |
-
noise_chars = list(string.ascii_letters + string.punctuation +
|
55 |
-
noise_chars.extend([''])
|
56 |
for index in noise_indices:
|
57 |
prompt_list[index] = random.choice(noise_chars)
|
58 |
return "".join(prompt_list)
|
@@ -74,7 +90,7 @@ def send_it2(inputs, noise_level, proc1=proc1):
|
|
74 |
return output2
|
75 |
|
76 |
def send_it3(inputs, noise_level, proc1=proc1):
|
77 |
-
prompt_with_noise =
|
78 |
while queue.qsize() >= queue_threshold:
|
79 |
time.sleep(2)
|
80 |
queue.put(prompt_with_noise)
|
|
|
31 |
queue = Queue()
|
32 |
queue_threshold = 100
|
33 |
|
34 |
+
#Don't add noise to the first picture no matter what (the point of noise is to get varied outputs, the first one doesn't need to vary about anything)
|
35 |
+
def noadd_random_noise(prompt, noise_level=0.00):
|
36 |
+
if noise_level == 0:
|
37 |
+
noise_level = 0.00
|
38 |
+
percentage_noise = noise_level * 5
|
39 |
+
num_noise_chars = int(len(prompt) * (percentage_noise/100))
|
40 |
+
noise_indices = random.sample(range(len(prompt)), num_noise_chars)
|
41 |
+
prompt_list = list(prompt)
|
42 |
+
noise_chars = list(string.ascii_letters + string.punctuation + '' + string.digits)
|
43 |
+
noise_chars.extend([''])
|
44 |
+
for index in noise_indices:
|
45 |
+
prompt_list[index] = random.choice(noise_chars)
|
46 |
+
return "".join(prompt_list)
|
47 |
+
|
48 |
+
#normal behavior
|
49 |
def add_random_noise(prompt, noise_level=0.00):
|
50 |
if noise_level == 0:
|
51 |
noise_level = 0.00
|
|
|
58 |
for index in noise_indices:
|
59 |
prompt_list[index] = random.choice(noise_chars)
|
60 |
return "".join(prompt_list)
|
61 |
+
|
62 |
+
#Give varied output even at noise level 0
|
63 |
+
def add_random_noise3(prompt, noise_level=0.00):
|
64 |
if noise_level == 0:
|
65 |
+
noise_level = 0.00
|
66 |
percentage_noise = noise_level * 5
|
67 |
num_noise_chars = int(len(prompt) * (percentage_noise/100))
|
68 |
noise_indices = random.sample(range(len(prompt)), num_noise_chars)
|
69 |
prompt_list = list(prompt)
|
70 |
+
noise_chars = list(' ' + string.ascii_letters + string.punctuation + string.digits)
|
71 |
+
noise_chars.extend(['๐', 'beautiful', '๐', '๐ค', '๐', '๐ค', '๐ญ', '๐', 'pretty', '๐คฏ', '๐คซ', '๐ฅด', 'sitting', '๐คฉ', '๐ฅณ', '๐', '๐ฉ', '๐คช', '๐', 'retro', '๐', '๐น', 'masterpiece', '๐ค', '๐ฝ', 'high quality', '๐', '๐
', '๐', '๐', '๐', '๐', '๐', '๐', '๐ฎ', 'โค๏ธ', '๐', '๐', '๐', '๐', '๐ถ', '๐ฑ', 'visible', '๐น', '๐ฆ', '๐ป', '๐จ', '๐ฏ', '๐ฆ', '๐', '๐ฅ', '๐ง๏ธ', '๐', '๐', '๐ฅ', '๐ด', '๐', '๐บ', '๐ป', '๐ธ', '๐จ', '๐
', '๐', 'โ๏ธ', 'โ๏ธ', 'โ๏ธ', 'โ๏ธ', '๐ค๏ธ', 'โ
๏ธ', '๐ฅ๏ธ', '๐ฆ๏ธ', '๐ง๏ธ', '๐ฉ๏ธ', '๐จ๏ธ', '๐ซ๏ธ', 'โ๏ธ', '๐ฌ๏ธ', '๐จ', '๐ช๏ธ', 'beautiful'])
|
72 |
for index in noise_indices:
|
73 |
prompt_list[index] = random.choice(noise_chars)
|
74 |
return "".join(prompt_list)
|
|
|
90 |
return output2
|
91 |
|
92 |
def send_it3(inputs, noise_level, proc1=proc1):
|
93 |
+
prompt_with_noise = add_random_noise3(inputs, noise_level)
|
94 |
while queue.qsize() >= queue_threshold:
|
95 |
time.sleep(2)
|
96 |
queue.put(prompt_with_noise)
|