Spaces:
Runtime error
Runtime error
phenomenon1981
commited on
Commit
ยท
1450cbb
1
Parent(s):
6f0b6f4
Update app.py
Browse files
app.py
CHANGED
@@ -29,17 +29,12 @@ queue_threshold = 100
|
|
29 |
def add_random_noise(prompt, noise_level=0.07):
|
30 |
if noise_level == 0:
|
31 |
noise_level = 0.07
|
32 |
-
# Get the percentage of characters to add as noise
|
33 |
percentage_noise = noise_level * 5
|
34 |
-
# Get the number of characters to add as noise
|
35 |
num_noise_chars = int(len(prompt) * (percentage_noise/100))
|
36 |
-
# Get the indices of the characters to add noise to
|
37 |
noise_indices = random.sample(range(len(prompt)), num_noise_chars)
|
38 |
-
# Add noise to the selected characters
|
39 |
prompt_list = list(prompt)
|
40 |
-
# Add numbers, special characters, and a selection of 100 popular emojis to the list of characters used to add noise
|
41 |
noise_chars = list(string.ascii_letters + string.punctuation + ' ' + string.digits)
|
42 |
-
noise_chars.extend(['๐', '๐ฉ', '๐', '๐ค', '๐', '๐ค', '๐ญ', '๐', '๐ท', '๐ค', '๐คฏ', '๐คซ', '๐ฅด', '๐ด', '๐คฉ', '๐ฅณ', '๐', '๐ฉ', '๐คฏ', '๐คช', '๐', '๐คข', '๐ท', '๐คฎ', '๐', '๐น', '๐ป', '๐ค', '๐ฝ', '๐', '๐', '๐
', '๐', '๐', '๐', '๐', '๐', '๐', '
|
43 |
for index in noise_indices:
|
44 |
prompt_list[index] = random.choice(noise_chars)
|
45 |
return "".join(prompt_list)
|
|
|
29 |
def add_random_noise(prompt, noise_level=0.07):
|
30 |
if noise_level == 0:
|
31 |
noise_level = 0.07
|
|
|
32 |
percentage_noise = noise_level * 5
|
|
|
33 |
num_noise_chars = int(len(prompt) * (percentage_noise/100))
|
|
|
34 |
noise_indices = random.sample(range(len(prompt)), num_noise_chars)
|
|
|
35 |
prompt_list = list(prompt)
|
|
|
36 |
noise_chars = list(string.ascii_letters + string.punctuation + ' ' + string.digits)
|
37 |
+
noise_chars.extend(['๐', '๐ฉ', '๐', '๐ค', '๐', '๐ค', '๐ญ', '๐', '๐ท', '๐ค', '๐คฏ', '๐คซ', '๐ฅด', '๐ด', '๐คฉ', '๐ฅณ', '๐', '๐ฉ', '๐คฏ', '๐คช', '๐', '๐คข', '๐ท', '๐คฎ', '๐', '๐น', '๐ป', '๐ค', '๐ฝ', '๐', '๐', '๐
', '๐', '๐', '๐', '๐', '๐', '๐', '๐ฎ', 'โค๏ธ', '๐', '๐', '๐', '๐', '๐ถ', '๐ฑ', '๐ญ', '๐น', '๐ฆ', '๐ป', '๐จ', '๐ฏ', '๐ฆ', '๐', '๐ฅ', '๐ง๏ธ', '๐', '๐', '๐ฅ', '๐ด', '๐', '๐บ', '๐ป', '๐ธ', '๐จ', '๐
', '๐'])
|
38 |
for index in noise_indices:
|
39 |
prompt_list[index] = random.choice(noise_chars)
|
40 |
return "".join(prompt_list)
|