Yntec commited on
Commit
eef378b
โ€ข
1 Parent(s): 7796057

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
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 dontaddnoise(prompt, nonoise=0.00):
48
- if nonoise == 0:
49
- nonoise = 0.00
50
- percentage_noise = nonoise * 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([''])
56
  for index in noise_indices:
57
  prompt_list[index] = random.choice(noise_chars)
58
- return "".join(prompt_list)
59
 
60
- def send_it1(inputs, nonoise, proc1=proc1):
61
- prompt_with_noise = dontaddnoise(inputs, nonoise)
62
  while queue.qsize() >= queue_threshold:
63
  time.sleep(2)
64
  queue.put(prompt_with_noise)
65
- output2 = proc1(prompt_with_noise)
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, nonoise], outputs=[output1])
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