phenomenon1981 commited on
Commit
2e1aad1
1 Parent(s): 6cb0860

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -44
app.py CHANGED
@@ -9,63 +9,56 @@ text_gen=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion")
9
 
10
 
11
  proc1=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
12
- proc2=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
13
- proc3=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
14
- proc4=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
15
-
16
  proc5=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
17
- proc6=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
18
- proc7=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
19
- proc8=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
20
 
21
- def add_random_noise(prompt):
22
- noise = "".join(random.choices(string.ascii_letters + string.punctuation, k=random.randint(1, 10)))
 
23
  return prompt + noise
24
 
25
- def send_it1(inputs,proc1=proc1):
26
- prompt_with_noise = add_random_noise(inputs)
27
  output1=proc1(prompt_with_noise)
28
  return output1
29
 
30
- def send_it2(inputs,proc2=proc2):
31
- prompt_with_noise = add_random_noise(inputs)
32
- output2=proc2(prompt_with_noise)
33
  return output2
34
 
35
- def send_it3(inputs,proc3=proc3):
36
- prompt_with_noise = add_random_noise(inputs)
37
- output3=proc3(prompt_with_noise)
38
  return output3
39
 
40
- def send_it4(inputs,proc4=proc4):
41
- prompt_with_noise = add_random_noise(inputs)
42
- output4=proc4(prompt_with_noise)
43
  return output4
44
 
45
- def send_it5(inputs,proc5=proc5):
46
- prompt_with_noise = add_random_noise(inputs)
47
  output5=proc5(prompt_with_noise)
48
  return output5
49
 
50
- def send_it6(inputs,proc6=proc6):
51
- prompt_with_noise = add_random_noise(inputs)
52
- output6=proc6(prompt_with_noise)
53
  return output6
54
 
55
- def send_it7(inputs,proc7=proc7):
56
- prompt_with_noise = add_random_noise(inputs)
57
- output7=proc7(prompt_with_noise)
58
  return output7
59
 
60
- def send_it8(inputs,proc8=proc8):
61
- prompt_with_noise = add_random_noise(inputs)
62
- output8=proc8(prompt_with_noise)
63
  return output8
64
 
65
  def get_prompts(prompt_text):
66
  return text_gen(prompt_text)
67
 
68
-
69
  with gr.Blocks() as myface:
70
  with gr.Row():
71
 
@@ -73,7 +66,8 @@ with gr.Blocks() as myface:
73
  see_prompts=gr.Button("Magic Prompt")
74
  with gr.Row():
75
 
76
- prompt=gr.Textbox(label="Enhanced Prompt")
 
77
  run=gr.Button("Generate")
78
 
79
 
@@ -90,16 +84,15 @@ with gr.Blocks() as myface:
90
  output7=gr.Image(label="DreamlikeArt Diffusion 3")
91
  output8=gr.Image(label="DreamlikeArt Diffusion 4")
92
 
93
- run.click(send_it1, inputs=[prompt], outputs=[output1])
94
- run.click(send_it2, inputs=[prompt], outputs=[output2])
95
- run.click(send_it3, inputs=[prompt], outputs=[output3])
96
- run.click(send_it4, inputs=[prompt], outputs=[output4])
97
- run.click(send_it5, inputs=[prompt], outputs=[output5])
98
- run.click(send_it6, inputs=[prompt], outputs=[output6])
99
- run.click(send_it7, inputs=[prompt], outputs=[output7])
100
- run.click(send_it8, inputs=[prompt], outputs=[output8])
101
  see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt])
102
 
103
-
104
- myface.queue(concurrency_count=2)
105
- myface.launch(enable_queue=True, inline=True)
 
9
 
10
 
11
  proc1=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
 
 
 
 
12
  proc5=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
 
 
 
13
 
14
+
15
+ def add_random_noise(prompt, noise_level=0.1):
16
+ noise = "".join(random.choices(string.ascii_letters + string.punctuation, k=int(noise_level * 10)))
17
  return prompt + noise
18
 
19
+ def send_it1(inputs, noise_level, proc1=proc1):
20
+ prompt_with_noise = add_random_noise(inputs, noise_level)
21
  output1=proc1(prompt_with_noise)
22
  return output1
23
 
24
+ def send_it2(inputs, noise_level, proc1=proc1):
25
+ prompt_with_noise = add_random_noise(inputs, noise_level)
26
+ output2=proc1(prompt_with_noise)
27
  return output2
28
 
29
+ def send_it3(inputs, noise_level, proc1=proc1):
30
+ prompt_with_noise = add_random_noise(inputs, noise_level)
31
+ output3=proc1(prompt_with_noise)
32
  return output3
33
 
34
+ def send_it4(inputs, noise_level, proc1=proc1):
35
+ prompt_with_noise = add_random_noise(inputs, noise_level)
36
+ output4=proc1(prompt_with_noise)
37
  return output4
38
 
39
+ def send_it5(inputs, noise_level, proc5=proc5):
40
+ prompt_with_noise = add_random_noise(inputs, noise_level)
41
  output5=proc5(prompt_with_noise)
42
  return output5
43
 
44
+ def send_it6(inputs, noise_level, proc5=proc5):
45
+ prompt_with_noise = add_random_noise(inputs, noise_level)
46
+ output6=proc5(prompt_with_noise)
47
  return output6
48
 
49
+ def send_it7(inputs, noise_level, proc5=proc5):
50
+ prompt_with_noise = add_random_noise(inputs, noise_level)
51
+ output7=proc5(prompt_with_noise)
52
  return output7
53
 
54
+ def send_it8(inputs, noise_level, proc5=proc5):
55
+ prompt_with_noise = add_random_noise(inputs, noise_level)
56
+ output8=proc5(prompt_with_noise)
57
  return output8
58
 
59
  def get_prompts(prompt_text):
60
  return text_gen(prompt_text)
61
 
 
62
  with gr.Blocks() as myface:
63
  with gr.Row():
64
 
 
66
  see_prompts=gr.Button("Magic Prompt")
67
  with gr.Row():
68
 
69
+ prompt=gr.Textbox(label="Enter Prompt")
70
+ noise_level=gr.Slider(minimum=0.1, maximum=1, step=0.1, label="Noise Level: Adjust noise level to explore different outputs. More noise, more variation. The noise level controls the level of randomness or variations added to the prompt before it is sent to the model. A higher noise level would introduce more variations to the prompt, while a lower noise level would introduce fewer variations.")
71
  run=gr.Button("Generate")
72
 
73
 
 
84
  output7=gr.Image(label="DreamlikeArt Diffusion 3")
85
  output8=gr.Image(label="DreamlikeArt Diffusion 4")
86
 
87
+ run.click(send_it1, inputs=[prompt, noise_level], outputs=[output1])
88
+ run.click(send_it2, inputs=[prompt, noise_level], outputs=[output2])
89
+ run.click(send_it3, inputs=[prompt, noise_level], outputs=[output3])
90
+ run.click(send_it4, inputs=[prompt, noise_level], outputs=[output4])
91
+ run.click(send_it5, inputs=[prompt, noise_level], outputs=[output5])
92
+ run.click(send_it6, inputs=[prompt, noise_level], outputs=[output6])
93
+ run.click(send_it7, inputs=[prompt, noise_level], outputs=[output7])
94
+ run.click(send_it8, inputs=[prompt, noise_level], outputs=[output8])
95
  see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt])
96
 
97
+ myface.queue(concurrency_count=8)
98
+ myface.launch(enable_queue=True, inline=True)