Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -44,25 +44,25 @@ def add_random_noise(prompt, noise_level=0.00):
|
|
44 |
prompt_list[index] = random.choice(noise_chars)
|
45 |
return "".join(prompt_list)
|
46 |
|
47 |
-
def
|
48 |
-
if
|
49 |
-
|
50 |
-
percentage_noise =
|
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 + '' + string.digits)
|
55 |
-
noise_chars.extend([''])
|
56 |
for index in noise_indices:
|
57 |
prompt_list[index] = random.choice(noise_chars)
|
58 |
-
return ""
|
59 |
|
60 |
-
def send_it1(inputs,
|
61 |
-
prompt_with_noise =
|
62 |
while queue.qsize() >= queue_threshold:
|
63 |
time.sleep(2)
|
64 |
queue.put(prompt_with_noise)
|
65 |
-
|
66 |
return output1
|
67 |
|
68 |
def send_it2(inputs, noise_level, proc1=proc1):
|
@@ -136,14 +136,13 @@ with gr.Blocks(css='style.css') as demo:
|
|
136 |
with gr.Row():
|
137 |
with gr.Row():
|
138 |
noise_level = gr.Slider(minimum=0.0, maximum=3, step=0.1, label="Noise Level")
|
139 |
-
nonoise=noise_level
|
140 |
with gr.Row():
|
141 |
with gr.Row():
|
142 |
output1=gr.Image(label="Dreamlike Anime 1.0",show_label=False)
|
143 |
output2=gr.Image(label="Dreamlike Anime 1.0",show_label=False)
|
144 |
|
145 |
see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt], queue=False)
|
146 |
-
run.click(send_it1, inputs=[prompt,
|
147 |
run.click(send_it2, inputs=[prompt, noise_level], outputs=[output2])
|
148 |
|
149 |
|
|
|
44 |
prompt_list[index] = random.choice(noise_chars)
|
45 |
return "".join(prompt_list)
|
46 |
|
47 |
+
def noadd_random_noise(prompt, noise_level=0.00):
|
48 |
+
if noise_level == 0:
|
49 |
+
noise_level = 0.00
|
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 + ' ' + string.digits)
|
55 |
+
noise_chars.extend(['๐', 'beautiful', '๐', '๐ค', '๐', '๐ค', '๐ญ', '๐', 'pretty', '๐คฏ', '๐คซ', '๐ฅด', 'sitting', '๐คฉ', '๐ฅณ', '๐', '๐ฉ', '๐คช', '๐', 'retro', '๐', '๐น', 'masterpiece', '๐ค', '๐ฝ', 'high quality', '๐', '๐
', '๐', '๐', '๐', '๐', '๐', '๐', '๐ฎ', 'โค๏ธ', '๐', '๐', '๐', '๐', '๐ถ', '๐ฑ', 'visible', '๐น', '๐ฆ', '๐ป', '๐จ', '๐ฏ', '๐ฆ', '๐', '๐ฅ', '๐ง๏ธ', '๐', '๐', '๐ฅ', '๐ด', '๐', '๐บ', '๐ป', '๐ธ', '๐จ', '๐
', '๐', 'โ๏ธ', 'โ๏ธ', 'โ๏ธ', 'โ๏ธ', '๐ค๏ธ', 'โ
๏ธ', '๐ฅ๏ธ', '๐ฆ๏ธ', '๐ง๏ธ', '๐ฉ๏ธ', '๐จ๏ธ', '๐ซ๏ธ', 'โ๏ธ', '๐ฌ๏ธ', '๐จ', '๐ช๏ธ', 'beautiful'])
|
56 |
for index in noise_indices:
|
57 |
prompt_list[index] = random.choice(noise_chars)
|
58 |
+
return ""
|
59 |
|
60 |
+
def send_it1(inputs, noise_level, proc1=proc1):
|
61 |
+
prompt_with_noise = noadd_random_noise(inputs, noise_level)
|
62 |
while queue.qsize() >= queue_threshold:
|
63 |
time.sleep(2)
|
64 |
queue.put(prompt_with_noise)
|
65 |
+
output1 = proc1(prompt_with_noise)
|
66 |
return output1
|
67 |
|
68 |
def send_it2(inputs, noise_level, proc1=proc1):
|
|
|
136 |
with gr.Row():
|
137 |
with gr.Row():
|
138 |
noise_level = gr.Slider(minimum=0.0, maximum=3, step=0.1, label="Noise Level")
|
|
|
139 |
with gr.Row():
|
140 |
with gr.Row():
|
141 |
output1=gr.Image(label="Dreamlike Anime 1.0",show_label=False)
|
142 |
output2=gr.Image(label="Dreamlike Anime 1.0",show_label=False)
|
143 |
|
144 |
see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt], queue=False)
|
145 |
+
run.click(send_it1, inputs=[prompt, noise_level], outputs=[output1])
|
146 |
run.click(send_it2, inputs=[prompt, noise_level], outputs=[output2])
|
147 |
|
148 |
|