phenomenon1981 commited on
Commit
0e527c5
1 Parent(s): aa474cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -13,9 +13,20 @@ proc1=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
13
  proc5=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
14
 
15
 
16
- def add_random_noise(prompt, noise_level=0.1):
17
- noise = "".join(random.choices(string.ascii_letters + string.punctuation, k=int(noise_level * 20)))
18
- return prompt + noise
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  queue_length_counter = 0
21
 
@@ -146,7 +157,7 @@ with gr.Blocks() as myface:
146
  with gr.Row():
147
 
148
  prompt=gr.Textbox(label="Enter Prompt")
149
- noise_level=gr.Slider(minimum=0.1, maximum=30, step=0.1, label="Noise Level: Controls how much randomness is added to the input before it is sent to the model. Higher noise level produces more diverse outputs, while lower noise level produces similar outputs.")
150
  run=gr.Button("Generate")
151
 
152
  with gr.Row():
 
13
  proc5=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
14
 
15
 
16
+ import random
17
+
18
+ def add_random_noise(prompt, noise_level=0.05):
19
+ # Get the percentage of characters to add as noise
20
+ percentage_noise = noise_level * 5
21
+ # Get the number of characters to add as noise
22
+ num_noise_chars = int(len(prompt) * (percentage_noise/100))
23
+ # Get the indices of the characters to add noise to
24
+ noise_indices = random.sample(range(len(prompt)), num_noise_chars)
25
+ # Add noise to the selected characters
26
+ prompt_list = list(prompt)
27
+ for index in noise_indices:
28
+ prompt_list[index] = random.choice(string.ascii_letters + string.punctuation)
29
+ return "".join(prompt_list)
30
 
31
  queue_length_counter = 0
32
 
 
157
  with gr.Row():
158
 
159
  prompt=gr.Textbox(label="Enter Prompt")
160
+ noise_level=gr.Slider(minimum=0.1, maximum=1, step=0.1, label="Noise Level: Controls how much randomness is added to the input before it is sent to the model. Higher noise level produces more diverse outputs, while lower noise level produces similar outputs.")
161
  run=gr.Button("Generate")
162
 
163
  with gr.Row():